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

When Value hits 100 on a player, it plays animation on them?

Ok, my last one got taken down for some reason, anyways let me be more CLEAR.

I changed it up a little bit, and this is a Local Script in the Players PlayerGui.

plr=game.Players.LocalPlayer
playr=script.Parent.Parent
char=plr.CharacterAdded:wait()
local player=workspace:findFirstChild(playr.Name)
local humanoid = player.Character.Humanoid

 player.Ankles.Changed:connect(function()
	if player.Ankles.Value==100 then
		local anim = Instance.new("Animation",char)
		anim.AnimationId = "http://www.roblox.com/asset/?id=529177665"
        local playAnim = humanoid:LoadAnimation(anim)
        playAnim:Play()
		script.Sound:Play()
		wait(3) -- How long until they get back up
		script.Sound:Stop()
		player.Ankles.Value=0
end
end)

I don't know where the problem is, and it doesnt show it in output. Please Help?

1 comment

0

Well, with programming, it depends on your spacing too. I'd recommend you to space some things out

1 answer

✓ Accepted answer

If you don't know the issue then we can't know either. Explain what are "Ankles", what is supposed to happen, what does not happen, what you have tried, context, etc. However I have done what can to make the script more safe and practical.

--define variables safely
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local humanoid = char:WaitForChild('Humanoid')
--assuming "Ankles" is inside the character...
local ankles = char:WaitForChild('Ankles')

--you only need to create one anim
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=529177665"

ankles.Changed:connect(function()
	if ankles.Value==100 then
		humanoid:LoadAnimation(anim):Play()
		script.Sound:Play()
		wait(3) -- How long until they get back up
		script.Sound:Stop()
		ankles.Value=0
	end
end)

2 comments

0

Well, the "ankles" isnt in the character, it's in the player in game.Players

0

But this still works when I change the ankles value to player:WaitForChild('Ankles') Thanks!

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