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

How do you make an animation play once a button is clicked?

Asked by 3 years ago

I need the animation "Kick" to play when a button is clicked, and im using a remote event to make the script in starter character scripts play animation, but it gives me an error of "unable to cast value to Object" on line 4??

local char = script.Parent
local event = game.ReplicatedStorage.RemoteEvents.StartAnimation
local AnimationTrack = game.StarterGui.ClickGUI.Main.Kick
local Animation = char.Humanoid:LoadAnimation(AnimationTrack.AnimationId)

event.OnServerEvent:Connect(function(player)
    if player.Name == char.Name then
        Animation:Play()
    end
end)

The event is being called from a localscript that works just fine

Answer this question