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

How could I play an animation through a clickdetector inside of a part?

Asked by
xudet 0
5 years ago

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
0
`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. TerrodactyI 173 — 5y
0
If you could put it into an answer that would be great xudet 0 — 5y

Answer this question