Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make an animation play when a part is clicked?

I have a clickdetector, an animation, and a localscript inside the part, this is the script that won't work. Its very simple but any help would be appreciated.

local anim = script.Parent.Animation
script.Parent.ClickDetector.MouseClick:Connect(function()
	anim:Play()
end)

1 answer

local Player = game.Players.LocalPlayer -- this also only works in LocalScripts
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")

script.Parent.ClickDetector.MouseClick:Connect(function()


local Animation = Instance.new("Animation") -- create a new animation object
Animation.AnimationId = "rbxassetid://00000" -- put your animation id over the zeroes

local Track = Humanoid:LoadAnimation(Animation)
Track:Play()
end)

please explain what you the animation to do next time

1 comment

0

I have a seatbelt and I want an animation to play when they click the belt on it.

This discussion is preserved as it was. New answers, comments, and votes are closed.