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

How to make animation play properly when tool is equipped?

Ok, so it's not as simple of an answer as you might think. Making an animation when equipping a tool is easy, but playing it properly is where I have a problem. What I mean by that is when you equip the tool it takes a few milliseconds for the animation to load and play, and when I make an equipped animation it will play after those few milliseconds, making the whole equipping thing weird because the tool can be seen in idle position and only after like 0.1 seconds the equip animation plays. What I'm trying to achieve is that the tool doesn't show up to the player once the animation has begun.

TLDR: the animation plays with a small delay, making the equipped animation play only 0.1 seconds after the tool is equipped.

local Tool = script.Parent
local anim = Tool:WaitForChild("Animation")
local Players = game:GetService("Players")
anim.AnimationId = "rbxassetid://8775729039"


Tool.Equipped:Connect(function(Mouse)
local player = Players:GetPlayerFromCharacter(Tool.Parent)
local animation = player.Character.Humanoid:LoadAnimation(anim)
animation:Play()
end)

GOAL: Make the animation play immediately when the tool is equipped, or don't show the tool for the small amount of time animation takes to load.

NOTE: If you have the idea of making the tool invisible then visible after a small amount of time don't bother answering, having 10 meshes each with unique texture in the tool makes it unethical to change the visibility of them all.

5 comments

0

Oh also ignore the fact animation only loads when the tool is equipped, The answer saying to make it load beforehand won't work for me, I really need to find a way to hide the tool once it starts playing or something like that

1

Animation delay happens ALL THE TIME! There's no fix to that. Every animation in every game has delays. Delay happens because of internet connection or servers shutting down.

0

@T3_MasterGamer You are correct, it does happen all the time, but every good fps game hides that somehow, and I need to know how to they do it.

0

I don't think they have a method for that.

0

One thing I could say is use Humanoid.Animator:LoadAnimation() instead of Humanoid:LoadAnimation()

1 answer

The best way is to just move the entire tool somewhere nobody can see it like under the map or something and then in the second frame move the tool to where you want it to be with the constant style.

Hope this helps!

(No, I don't mean to make the tool invisible and then visible again)

4 comments

0

Well I get your idea, I assume you are talking about the animation itself, in which case it won't work, since the animation still has to load, and will show the idle position while it does.

0

Maybe you were thinking about offsetting the gun with a script, not an animation, in which case it would work, but not perfectly, let's say I added a 0.1 second delay to a function that positions the tool in correct position once equipped, it wouldn't be the same for everyone, since others have slower devices and it would still sometimes display the idle pose if the animation didn't get to load

0

So in my opinion the best way to go around this is by having a script wait for the animation to load, then once it has loaded, play the animation and change the guns offset to correct position.

0

Okay

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