Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make Proximity Prompt Play Animation?

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.