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

How to make player play an animation?

Asked by
14dark14 167
4 years ago
local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
script.Parent.ScreenGui.TextButton.MouseButton1Click:Connect(function()
        animation:Play()
        wait(1) 
end)

LocalScript inside StartGUI

When you press a button the animation will play but it didnt

2 answers

Log in to vote
2
Answered by 4 years ago

You're over thinking it

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded
local hum = char:WaitForChild("Humanoid")

script.Parent.MouseButton1Click:connect(function()
    local anim = hum:LoadAnimation(script.Parent.Animation)
    anim:Play()
end)

and make sure that your animation priority is set as action if its an animation that is quick and isn't looped

0
and make sure u put the local script inside the button and make sure the animation is in the button too JustPapi 49 — 4y
0
works 14dark14 167 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Buttons use the activated event, not the mousebutton1down event

try this:

local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
script.Parent.ScreenGui.TextButton.Activated:Connect(function()
        animation:Play()
        wait(1)
end)

0
dont work 14dark14 167 — 4y

Answer this question