Hi scripters. I’ve ran into a problem while trying to create a food animation system for ice cream. This is the current script I’m using:
local Tool = script.Parent
local EatAnimation = Tool.EatAnimation
Tool.Activated:Connect(function()
local Character = Tool.Parent
local AnimationTrack = Character.Humanoid:LoadAnimation(EatAnimation)
AnimationTrack:Play()
end)
For some reason, it doesn’t work when I click while holding the tool. This is what it looks like in studio:
As you can see, the parts are welded together. I’m not sure if this is something to do with the script, animation, or what. The animation is a valid animation and I know that. The weird thing is that there are no errors in the output/console. If you guys can help me that would be amazing. Thanks!
Thank you! Honestly, I don’t even know what went through my mind doing that. However, it unfortunately still does not work. This is the script now:
local Tool = script.Parent
local EatAnimation = Tool.EatAnimation
Tool.Activated:Connect(function()
local Character = Tool.Parent
local AnimationTrack = Character.Humanoid:LoadAnimation(EatAnimation)
AnimationTrack:Play()
end)
-- pretty easy, you just add one little piece of code:
local Tool = script.Parent
local EatAnimation = Tool.EatAnimation
Tool.Activated:Connect(function()
local Character = Tool.Parent
local AnimationTrack = Character.Humanoid.Animator:LoadAnimation(EatAnimation) -- this is where we change it
-- however, your code might not be working because the animation hasnt loaded. to fix this, you might just be able to do this:
repeat task.wait() until AnimationTrack.Length > 0.05
AnimationTrack:Play()
end)
Can you add a print() function inside of tool.activated? Example:
-- pretty easy, you just add one little piece of code:
local Tool = script.Parent
local EatAnimation = Tool.EatAnimation
Tool.Activated:Connect(function()
print("activated")
local Character = Tool.Parent
local AnimationTrack = Character.Humanoid.Animator:LoadAnimation(EatAnimation) -- this is where we change it
-- however, your code might not be working because the animation hasnt loaded. to fix this, you might just be able to do this:
repeat task.wait() until AnimationTrack.Length > 0.05
AnimationTrack:Play()
end)
does “activated” print?
Well, imma go to sleep. Hopefully you fix your problem tmrw. See you.
Activated does not print normally, but I found something out. For whatever reason, it works when it’s in the starterpack but not when I get it how I normally get it. It’s very weird…