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

why my animation doesnt want to play?

Hi, im trying to play an animation when the player clicks, but nothing is happening. There is also no output.

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/Asset?ID=2309234897"
local char = plr:WaitForChild("Character")
local equipped = false
local tool = script.Parent

mouse.Button1Down:Connect(function()
	if equipped == true then
		local animTrack = char.Humanoid:LoadAnimation(anim)
		animTrack:Play()
		wait(2)
	end
end)

tool.Equipped:Connect(function()
	equipped = true
end)

tool.Unequipped:Connect(function()
	equipped = false
end

4 comments

0

Do you have the animation published? aka Exported?

0

Yes i uploaded it

0

Is it a local or a normal script?

1

Local script in a tool

1 answer

Maybe, this will work, We can try switching the statements, by making the equipped function first and then the mouse.Button1Down

localscript:

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/Asset?ID=2309234897"
local char = plr:WaitForChild("Character")
local equipped = false
local tool = script.Parent

tool.Equipped:Connect(function()
 mouse.Button1Down:Connect(function()
     local animTrack = char.Humanoid:LoadAnimation(anim)
     animTrack:Play()
     wait(2)
 end)
end)

4 comments

0

Looks solid too me.

0

I agree looks quite good.

0

Sadly doesnt work maybe my animation doesnt work

0

Sorry for the late response, try adding prints between each line

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