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

How to trigger animation when button is clicked?

Asked by 3 years ago

Not really a scripting question, but I have a script that plays an animation, but no one else can actually "do" the animation, because they do not own the animation. Is there a way to work around this? Here's my code btw:

script.Parent.Jump.MouseButton1Click:Connect(function()
    animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(game.Workspace.JumpAnim)
    animation:Play()
end)

script.Parent.Cheer.MouseButton1Click:Connect(function()
    animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(game.Workspace.CheerAnim)
    animation:Play()
end)

script.Parent.Wave.MouseButton1Click:Connect(function()
    animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(game.Workspace.WaveAnim)
    animation:Play()
end)

script.Parent.Kick.MouseButton1Click:Connect(function()
    animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(game.Workspace.KickAnim)
    animation:Play()
end)

script.Parent.Float.MouseButton1Click:Connect(function()
    animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(game.Workspace.FloatAnim)
    animation:Play()
end)

1 answer

Log in to vote
0
Answered by 3 years ago

I would use the UserInputService, and when they press a key, it plays an Animation. I would put this into a local script, inside starter pack.

0
Sorry i cant post an example, im on my phone right now. mcslimeman 37 — 3y
Ad

Answer this question