Pls help with my animation on click script

Hello, I am a newbie scripter, what was my mistake here?
help pls



2 Likes

I may be wrong about this but try setting the animation variable in your server script to game.Workspace.Glass.Script.Animation. The local script probably thinks that the animation is relative to itself.

1 Like

ok i just tried this but the same error still occurs

Maybe try to rename your script to something else. It seems like you have two scripts with the same name. If that doesn’t work, maybe try using :WaitForChild("Animation") or :FindFirstChild("Animation")

yes i know, i’ve renamed my script bc when trying to locate animation i couldn’t, so i’ve renamed the script but it still doesn’t work…

Try printing the player and animation and see what it says


Okay for some reason when printing plr animation was printed and when printing animation an error occurred.

Did you do print(plr.Name) or print(plr)?

plr.Name and Animation.Name

print(plr.Name)
print(animation.Name)
end)

Wait, I just realized the issue. You are trying to run the animation on a player in game.Players, not game.Workspace.

In your click script, try doing something like

clickDetector.MouseClick:Connect(function(plr)
local workspacePlayer = game.Workspace:FindFirstChild(plr.Name)
workspacePlayer.Humanoid:LoadAnimation(animation):Play()
end)

EDIT: I learned that player.character is a thing so you should probably do this instead:

clickDetector.MouseClick:Connect(function(plr)
local Humanoid = plr.Character:FindFirstChild("Humanoid")
Humanoid:LoadAnimation(animation):Play()
end)
2 Likes

Oh!, ok it is now working, without the remote event system but it is working! Thank you very much!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.