Animation Code NOT working

local Parent = script.Parent
local LocalPlayer = game.Players.LocalPlayer
while true do
	wait()
	if LocalPlayer.Character then
		break
	end
end
wait(1)
local Animation = Instance.new("Animation", Parent)
Animation.AnimationId = "rbxassetid://13288897462"
local Toggled = false
local AnimationLoad = LocalPlayer.Character:WaitForChild("Humanoid"):LoadAnimation(Animation)
Parent.Equipped:connect(function(Mouse)
	Mouse.Icon = ""
	Mouse.Button1Down:connect(function()
		if Toggled then
			AnimationLoad:Stop()
			Toggled = false
			return
		end
		AnimationLoad:Play()
		Toggled = true
	end)
end)

When I click, it doesn’t work.

the error maybe on Mouse.Icon = '' since you cant set mouse icon to nil i think

Okay. Let me see.
character character character

1 Like

Nope. still not working. characrter character

is your animation saved on your account/group? and not someone else?

Yes. The animation is uploaded. eeeeeee

try to change the animation priority

set it to action

Ok. eeeeeeeeeeeeeeeeeeeeeeeeeeeee

here i have some Animation.Priority= Enum.AnimationPriority.Action

“Priority is not a valid property of instance “Animation””

When uploaded, it was already an action.

1 Like

What kind of animation are you trying to play?

A simple salute animation. When the tool is equiped and you click, it should play it.

local Parent = script.Parent
local LocalPlayer = game.Players.LocalPlayer
while true do
	wait()
	if LocalPlayer.Character then
		break
	end
end
wait(1)
local Animation = Parent.Animation
local Toggled = false
local AnimationLoad = LocalPlayer.Character:WaitForChild("Humanoid"):LoadAnimation(Animation)
Parent.Equipped:connect(function(Mouse)
	Mouse.Icon = ""
	Mouse.Button1Down:connect(function()
		if Toggled then
			AnimationLoad:Stop()
			Toggled = false
			return
		end
		AnimationLoad:Play()
		Toggled = true
	end)
end)

I modified it. But it still doesn’t work.

Is this animation supposed to be in a loop?

Yeah. It’s supposed to just keep playing until it’s toggled off.

In that case, first make sure that you’ve enabled the loop inside the editor. second, replace this part of the code

if Toggled then
	AnimationLoad:Stop()
	Toggled = false
else
	AnimationLoad:Play()
	Toggled = true
end
1 Like

Still doesn’t work. eeeeeeeeee

Alright, there might be another problem. if this is a group game, make sure the animation is uploaded on the group and not on your profile.

It is uploaded correctly. eeeee