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

Way to play an animation when a BoolValue's Value = true?

Asked by 8 years ago

I tried this script, but it wasn't working. Please Help!

if script.Parent.PlayOverhead.Value == true then
    game.Players.LocalPlayer:WaitForChild("Character"):WaitForChild("Humanoid")
:LoadAnimation(script.Parent.OverheadAnim2)
    game.Players.LocalPlayer:WaitForChild("Character"):WaitForChild("Humanoid")
:PlayAnimation(script.Parent.OverheadAnim2)
end

Thanks!

0
AnimationName:Play(). woodengop 1134 — 8y

1 answer

Log in to vote
0
Answered by
Traide -2
8 years ago

First of all the script only runs once in the whole entire time you play the game.

For the script to check if a value is true, you want the script to load the animations only when the boolean is changed.

So we should make a changed event.

script.Parent.PlayOverhead.Changed:connect(function()
if script.Parent.PlayOverhead.Value == true then
    game.Players.LocalPlayer:WaitForChild("Character"):WaitForChild("Humanoid")
:LoadAnimation(script.Parent.OverheadAnim2)
    game.Players.LocalPlayer:WaitForChild("Character"):WaitForChild("Humanoid")
:PlayAnimation(script.Parent.OverheadAnim2)
end
end)
Ad

Answer this question