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

How to make animation play properly when tool is equipped?

Asked by
14dark14 167
1 year ago

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"

local player = Players:GetPlayerFromCharacter(Tool.Parent)
local animation = player.Character.Humanoid:LoadAnimation(anim)

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.

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 14dark14 167 — 1y
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. T3_MasterGamer 2189 — 1y
@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. 14dark14 167 — 1y
I don't think they have a method for that. T3_MasterGamer 2189 — 1y
One thing I could say is use Humanoid.Animator:LoadAnimation() instead of Humanoid:LoadAnimation() T3_MasterGamer 2189 — 1y

1 answer

Log in to vote
Answered by 1 year ago

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)

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. 14dark14 167 — 1y
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 14dark14 167 — 1y
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. 14dark14 167 — 1y
Okay GamerLighting23233 63 — 1y

Answer this question