Greetings, I have a part and a clickdetector and I was just curious on how I would go about playing the animation through localplayer when they click the button I have this little code here but I'm not so sure if its correct so could anyone give me some advice or correct the code, that would be most appreciated thanks.
local animation = Instance.new("Animation")
animation.AnimationId = "https://www.roblox.com/library/2842637376/T-Pose"
local trackanimation = nil
local playabillity = true
function playAnimation(AnimationSource)
if playabillity == true then
local plr = game.Players.LocalPlayer
trackanimation = plr.Character.Humanoid:LoadAnimation(animation)
trackanimation.KeyframeReached:connect(function()
print("Working")
end)
trackanimation:Play()
end
end

2 comments
WhateverClickdetector.MouseClick:Connect(playAnimation)Is this what you need? I can put it into an answer if you like, but it's just a guess.If you could put it into an answer that would be great