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

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

Asked by 8 years ago
Edited 8 years ago

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.

01plr=game.Players.LocalPlayer
02playr=script.Parent.Parent
03char=plr.CharacterAdded:wait()
04local player=workspace:findFirstChild(playr.Name)
05local humanoid = player.Character.Humanoid
06 
07 player.Ankles.Changed:connect(function()
08    if player.Ankles.Value==100 then
09        local anim = Instance.new("Animation",char)
10        anim.AnimationId = "http://www.roblox.com/asset/?id=529177665"
11        local playAnim = humanoid:LoadAnimation(anim)
12        playAnim:Play()
13        script.Sound:Play()
14        wait(3) -- How long until they get back up
15        script.Sound:Stop()
16        player.Ankles.Value=0
17end
18end)

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

0
Well, with programming, it depends on your spacing too. I'd recommend you to space some things out TheePBHST 154 — 8y

1 answer

Log in to vote
0
Answered by
cabbler 1942 Moderation Voter
8 years ago

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.

01--define variables safely
02local player = game.Players.LocalPlayer
03local char = player.Character or player.CharacterAdded:wait()
04local humanoid = char:WaitForChild('Humanoid')
05--assuming "Ankles" is inside the character...
06local ankles = char:WaitForChild('Ankles')
07 
08--you only need to create one anim
09local anim = Instance.new("Animation")
11 
12ankles.Changed:connect(function()
13    if ankles.Value==100 then
14        humanoid:LoadAnimation(anim):Play()
15        script.Sound:Play()
16        wait(3) -- How long until they get back up
17        script.Sound:Stop()
18        ankles.Value=0
19    end
20end)
0
Well, the "ankles" isnt in the character, it's in the player in game.Players Resplendid 3 — 8y
0
But this still works when I change the ankles value to player:WaitForChild('Ankles') Thanks! Resplendid 3 — 8y
Ad

Answer this question