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 7 years ago
Edited 7 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.

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?

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

1 answer

Log in to vote
0
Answered by
cabbler 1942 Moderation Voter
7 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.

--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)
0
Well, the "ankles" isnt in the character, it's in the player in game.Players Resplendid 3 — 7y
0
But this still works when I change the ankles value to player:WaitForChild('Ankles') Thanks! Resplendid 3 — 7y
Ad

Answer this question