Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make Proximity Prompt Play Animation?

Asked by 3 years ago
local ProximityPrompt = script.Parent
local Health = script.Parent.Health

ProximityPrompt.Triggered:Connect(function(epic)
    local human = epic.Parent:WaitForChild("Humanoid")
    local poop = human:LoadAnimation(script.Parent.Kick)
    poop:Play()
    Health.Value = Health.Value - 10
end)


if Health == 0 then
    script.Parent.Parent.Parent.Primary.Anchored = false
    script.Parent.Parent.Sound:Play()
    wait(0.1)
    script.Parent.Parent.ProximityPrompt:Destroy()
end

1 answer

Log in to vote
0
Answered by
imacodr 40
3 years ago

Your code isn't working because you are getting the player instead of its character. This is how it would be:

local ProximityPrompt = script.Parent
local Health = script.Parent.Health

ProximityPrompt.Triggered:Connect(function(player)
    local human = player.Character:WaitForChild("Humanoid")
    local animation = human:LoadAnimation(script.Parent.Kick)
    animation:Play()
    Health.Value = Health.Value - 10
end)


if Health == 0 then
    script.Parent.Parent.Parent.Primary.Anchored = false
    script.Parent.Parent.Sound:Play()
    wait(0.1)
    script.Parent.Parent.ProximityPrompt:Destroy()
end

(I also don't suggest using random words as variables since you can easily get lost in your code)

Ad

Answer this question