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

Animation isn't playing when unequipped?

How do I make the animation play when the tool un-equips? I have a print that tells when it plays, but it isn't at all. No errors were showing, and no prints were showing (except the Humanoid error, but that doesn't matter. Animation still works.)

Code Leading to the tool:

Tool = script.Parent
local tool = script.Parent
local player = game.Players.LocalPlayer
local Character = player.Character
local players = game:GetService("Players")
local SG = game:GetService("StarterGui")

Note: I can't remove Tool = script.Parent and local tool = script.Parent or it'll break.

Unequipped code:

Tool.Unequipped:Connect(function()
local animation = Instance.new("Animation")
		animation.Name = "Idle"
		animation.AnimationId = "http://www.roblox.com/Asset?ID=4638055721"
		local animTrack = tool.Parent.Humanoid:LoadAnimation(animation)
		animTrack:Play()
print("I'm working on it!") --This needs to show, but the animation is blocking it for some reason
game.Lighting.Bloom.Enabled = false
game.Lighting.ColorCorrection.Enabled = false
game.Lighting.Ambient = Color3.new(0/255, 0/255 ,0/255) --Ignore the lighting effects
end)

3 comments

0

Try parenting the animation somewhere first like the tool then load it. I think animations don't load if they're not parented anywhere.

0

You are loading the animation into the players' backpacks :/

0

Prism, equipping the animation works, unequipping doesn't

1 answer

Found the Answer with some help!

Tool.Unequipped:Connect(function()
local G = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(tool.(AnimationName))
G:Play()
print("I'm working on it!")
game.Lighting.Bloom.Enabled = false
game.Lighting.ColorCorrection.Enabled = false
game.Lighting.Ambient = Color3.new(0/255, 0/255 ,0/255)
end)

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