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

Why are animations only working inside of the studio, and not in the game?

Asked by 3 years ago
Edited 3 years ago

Hello! So I made a sitting animation and a eating animation, and when I test it out in the roblox studio, it works perfectly. But then when I go in game on regular roblox, neither of the animations work. Does anyone know why this might be happening? I will put the code for the eating animation below, but I don't think it has anything to do with my problem.



local Tool = script.Parent local EatAnimation = Tool.Animation Tool.Equipped:Connect(function(Mouse) Tool.Activated:Connect(function() local Character = Tool.Parent local AnimationTrack = Character.Humanoid:LoadAnimation(EatAnimation) AnimationTrack:Play() end) end)

Thank you in advance!

1 answer

Log in to vote
0
Answered by 3 years ago

Firstly, make sure you are using a LocalScript. The animation will replicate to the server so you dont have to worry about remotes for this part.

local toolObject = script.Parent
local eatAnimation = toolObject:WaitForChild("Animation")
local character = game.Players.LocalPlayer.Character

local eatAnimationTrack = Character.Humanoid:LoadAnimation(eatAnimation)

-- Fired when the player clicks while a tool is equipped.
toolObject.Activated:Connect(function()
        eatAnimationTrack:Play()
end)

I removed the Equipped listener because it is unnecessary since the ".Activated" event only fires when the tool is equipped. Also, I placed the LoadAnimation() outside of the listener function because we only want to load it in once, not every time the tool is activated.

0
I tried your script in a local script and then it didnt even work inside of the studio. Maybe I am doing something else wrong? H0ney_Beeee 8 — 3y
0
One, is the LocalScript located in side of the tool. Is there an instance called "Animation" with an AnimationID located inside of the tool? YTRaulByte 389 — 3y
0
I looked through the script, and I applied it all to my studio, and instead you just cant pick it up at all anymore. H0ney_Beeee 8 — 3y
0
I have no idea what you did, this section of code is supposed to play an animation on mouse click. It is supposed to be located in the Tool as a localscript YTRaulByte 389 — 3y
View all comments (6 more)
0
Do you know how I could add a photo to this site? Like a screenshot, maybe I messed something up. H0ney_Beeee 8 — 3y
0
Oh this is in workspace by the way, dont know if that has anything to do with it. H0ney_Beeee 8 — 3y
0
Is there anything being shown on your output log YTRaulByte 389 — 3y
0
Nothing in the output log.. Same problem as before. Even with your script, it is working perfectly in the studio. But when you go to the actual game on roblox, the animation doesnt work. H0ney_Beeee 8 — 3y
0
Also, thank you for helping me with the problem, I really do appreciate it. H0ney_Beeee 8 — 3y
0
Ok, I troubleshooted some more and I figured it out! Thank you so much for helping me, I really appritiate it! H0ney_Beeee 8 — 3y
Ad

Answer this question