Roblox,在与零件接触时损坏玩家



我的代码:

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Activation = 
Instance.new("Sound",game.Players.LocalPlayer.Character.Head)
local char = Player.Character
local hum = char.Humanoid
local root = char.HumanoidRootPart
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.F then
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://1581972610"
local animTrack = hum:LoadAnimation(animation)
animTrack:Play()
Activation.SoundId = "rbxassetid://1581091676" --Plays Mangekyou Sharingan Activation Sound.
Activation:Play()
wait(0.3)       
game.Players.LocalPlayer.Character.Head.face.Texture = "rbxassetid://76285632" --When F is pressed, face texture changes to sharingan decal.
game:GetService("Chat"):Chat(Player.Character.Head, "Mangekyou Sharingan!")
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.R then
Activation.SoundId = "rbxassetid://1580990602" --Plays Amaterasu Activation Sound.
Activation:Play()
game:GetService("Chat"):Chat(Player.Character.Head, "Amaterasu!")
local Target = Instance.new("Part") --makes a part
Target.CFrame = Mouse.Hit; --Makes part spawn at the mouse's current location in game
Target.Parent = game.Workspace
Target.Transparency = 1 
Target.Anchored = true 
Target.CanCollide = false 

local Amaterasu = Instance.new("Fire")
Amaterasu.Parent = game.Workspace.Part
Amaterasu.Color = Color3.new(0,0,0)
Amaterasu.SecondaryColor = Color3.new(0,0,0) --amaterasu properties
Amaterasu.Size = 25
local R = Instance.new("RocketPropulsion") --rocket propulsion, parents amaterasu
R.Parent = Amaterasu
R.MaxThrust = 300
R.ThrustP = 30
R:Fire()
end
end)
 UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.G then
game.Players.LocalPlayer.Character.Head.face.Texture = "rbxassetid://22557247" --When G is pressed, face texture changes back to normal.(leaves face blank isnt working :/)
end
end)

我正在研究此脚本中的第二个函数,如果按下"r"键就会激活该函数。该函数通过按"r"键使零件生成到鼠标的当前位置,其中有火焰。

这都可以正常工作。我希望生成的火焰对它接触的任何玩家造成一定数量的生命值,在这种情况下,我希望伤害为 100 生命值。

我相信你要找的是感动的 - 请参阅创建危险陷阱:https://wiki.roblox.com/index.php?title=Creating_Traps_and_Pickups

文档中提供的示例:

local trapPart = script.Parent
local function onPartTouch(otherPart)
    local partParent = otherPart.Parent
    local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
    if ( humanoid ) then
        -- Set player's health to 0
        humanoid.Health = 0
    end
end
trapPart.Touched:Connect(onPartTouch)

但免责声明 - 不是 Roblox 开发人员(现在只是窃听一个(。

祝你好运。

在设置属性之前不要创建父级,否则会导致性能滞后

最新更新