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

How make click decetor animation?

I make animation and idk how play this animation on local player when click detector gonna be clicked.

local animation = Instance.new("Animation") local click = game.Workspace.button.button2.ClickDetector local track = nil animation.AnimationID = "https://www.roblox.com/Asset?ID = 4914456849"

click.MouseClick:Connect(function() local plr = game.Players.LocalPlayer track = plr.Character.Humanoid:LoadAnimation (animation) animation:Play() end)

1 answer

what you can do is there is a parameter when you click a clickdetector which is the player that clicked the button, so you can do

-- Put this inside the clicking part
local animation = Instance.new("Animation")
local click = script.Parent.ClickDetector
local track
animation.AnimationId = "https://www.roblox.com/asset?id=4914456849"

click.MouseClick:Connect(function(player) -- Getting the player that clicked the button
	local character = player.CharacterAdded:Wait() -- Waiting for the character
	if character:FindFirstChild("Humanoid") and track == nil then
		track = character.Humanoid:LoadAnimation(animation)
		track:Play()
	end
end)

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