Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Animation isn't playing when unequipped?

Asked by 4 years ago

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)
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. User#20279 0 — 4y
0
You are loading the animation into the players' backpacks :/ PrismaticFruits 842 — 4y
0
Prism, equipping the animation works, unequipping doesn't TheBuliderMC 84 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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)
Ad

Answer this question