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

Play animation on MouseClick?

Asked by 6 years ago

Basically, I want it so that an animation plays when the player clicks the part. This is my code:

local s = script.Parent
local animation = s.Eating_anim
local Player = game:GetService("Players").LocalPlayer
local animTrack = Player.Character.Humanoid:LoadAnimation(animation)

s.ClickDetector.MouseClick:connect(function()
    animTrack:Play()
end)

I currently do not know what the error is, and no error was printed out. I am using a LocalScript. Anyone help please?

0
localscripts only run in players, and player characters (not npc's) change it to normal script fanofpixels 718 — 6y

1 answer

Log in to vote
0
Answered by
Griffi0n 315 Moderation Voter
6 years ago
Edited 6 years ago

Local Scripts don't run in the workspace. If you change it to a Script and make some minor adjustments then it should work.

0
What do you mean by minor adjustments... Florian27 76 — 6y
Ad

Answer this question