Animation wont run D:

this problem is in the script as I tried using print(“working”), successfully of course, but still I cant figure this out.
Any help?

local Bell = workspace.bellmodel.Bell.bellhitbox

local Animation = Instance.new(“Animation”)
Animation.AnimationId = “rbxassetid://14503813709”

Bell.ClickDetector.MouseClick:Connect(function(player)
local Character = player.Character

if Character then
local Humanoid = Character:WaitForChild(“Humanoid”)

  local Track = Humanoid.Animator:LoadAnimation(Animation)
  Track:Play()

end
end)

4 Likes

this is all one code block have no clue what happened lol
also big help from @1pad_a1r for getting me here :]

3 Likes

Either because you didn’t parent the Animation
Or your animation have problem with priority
if not idk:/
(Also i think this post should be scripting support not code review)

4 Likes

Do you make the animation? If you don’t, it might not work. If it’s your’s, are you the owner of the place or game? Sorry lots of question.

2 Likes

Ill edit the title to be scripting support but how could I Parent an Animation?
also the game and animation are mine to answer @Jando_123456’s question

2 Likes

Nvm my bad i were testing without parenting and it still work so have you checked your animation priority?

1 Like

Hello doominick,

Paste this code right before you play the animation:

Track.Priority = Enum.AnimationPriority.Action
Track.Looped = false
2 Likes

alr lemme try
limit30303030303030

1 Like

the >Track.Priority = Enum.AnimationPriority.Action
causes an error that says “attempt to index nil with property”

1 Like

Instead of setting the variable Track as:

local Track = Humanoid.Animator:LoadAnimation(Animation)

Set it as this:

local Track = Humanoid:LoadAnimation(Animation)
1 Like

how long is the animation? it might be because the animatuon is short

1 Like

try parenting animation into somewhere exists like
Animation.Parent = workspace

if you want to destroy after specific time use debris

2 Likes

Start the debugging process and see what It prints:

local Bell = workspace.bellmodel.Bell.bellhitbox

local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://14503813709"

Bell.ClickDetector.MouseClick:Connect(function(player)
	print("Bell clicked by", player.Name)
	local Character = player.Character

	if Character then
		print("Character found")
		local Humanoid = Character:WaitForChild("Humanoid")

		if Humanoid then
			print("Humanoid found")
			local Track = Humanoid.Animator:LoadAnimation(Animation)
			Track:Play()
			print("Animation played")
		else
			warn("Humanoid not found in character")
		end
	else
		warn("Character not found for player")
	end
end)

1 Like

I said i tested it and it still worked

1 Like

Just set animation priority in Animation Editor and reupload it rather than doing this

1 Like
-- inside function script
local Character = player.Character
local Humanoid = player:FindFirstChild("Humanoid")

local Animation = -- bla bla bla
Animation.Parent = -- the part or character

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

Try this one inside the function script

1 Like

I don’t think you need the 2nd line. My bad.