How Would I Go About Doing This?

(Not sure if it’s Prgoramming or Building, tell me which it is and I’ll move this)
Hello fellow Developers!
I have a question, so currently if I had an equip Animation and I play it, it wouldn’t work, and it would simply spawn the Tool after the Animation finished, but how would I go about making the Tool appear when the Animation is playing?
(The script I have is simply something like:

local function onEquip()
   animation:Play()
   animation.Ended:Wait()
   equipped = true
end

tool.Equipped:Connect(onEquip)

It’s useless in this case as I’m simply asking if it’s even possible)

1 Like

You should move this to #help-and-feedback:scripting-support

So from what I understand, you want a tool to be equipped once the animation starts playing, correct? If so, all you should do is play the animation first and call the Equip() function to the humanoid.

Example:

local tool -- your tool
local hum -- your humanoid
local anim -- your animation

-- after a given circumstance
animation:Play()
hum:EquipTool(tool)

Where is the script located?
What type of script is it, local or server?

Sorry, I forgot to tell, it’s a LocalScript on the tool

Can you show me the full script?

I can provide the script, but I need to write it form my mind as I’m not at my PC right now, there’s Variables for the Humanoid, Tool, Aninations, Animatior, Character, and the Functions are:

local function onEquip()
   print(“Equipped”)
   equipAnim:Play()
   equipAnim.Ended:Wait()
   equipped = true
end

local function onUnequip()
   print(“unequipped”)
   unequipAnim:Play()
   unequipAnim.Ended:Wait()
   equipped = false
end

tool.Equipped:Connect(onEquip)
tool.Unequipped:Connect(onUnequip)

I can’t remember the exact path for the Variavbles tho

Everything works fine, only that the Animation plays but the tool appears only after the Animation ended when equipped, and stays mid-air when unequipped and then disappears

Is it okay to wait till I get home? It looks and sounds like everything should be working fine, but I could look into it more when I can access my computer.

1 Like

Sorry for the late reply, if you want I can explain more the problem, I’m not at my PC right now, but I will try to explain
So, when I equip, this happens, the animation plays, but the sword appears only when the animation finishes, but when I unequip it, it stays in place until the animation finishes

When you can, can you show me a video of the issue. Maybe even send the place file?

is this what you mean?

local hum = script.parent.parent:FindFirstChild("Humanoid")
local Animation = -- where its located
local function onEquip()
local anim = hum.loadAnimation:(Animation)
   anim:Play()
   anim.Ended:Wait()
   equipped = true
end

tool.Equipped:Connect(onEquip)

try this

1 Like

(I’m not gonna send the place file because I don’t know how to do that and I don’t wnat other people to have access to it, security purposes) and for the video I will share it when I can (even though I can’t from my PC fro some reason)

You can send the place file through DMs if you wish, but it is okay if you don’t. And to actually get the place file, it’s very simple. When in studio, you click file → save to file as
It will save the place file, which you can then send. But again, it’s okay if you don’t. It just makes solving this a bit more simple

do you mean when the tool is equipped the anim plays?

No, the animation plays, and the tool appears after the animation ends

o well…
you need to duplicate the handle name it “mainpart” or anything you want, then insert a new dummy
put the tool inside the dummy then “Motor6D” the handle with the part i named Mainpart then rig the dummys arm to the handle also done by “Motor6D” btw make the Handle invisible
then create an animation and make the weapon/tool appear from under the player or how you like it

1 Like

It’s the order you are doing the function, as @BabyNinjaTime said.

   animation:Play()
   animation.Ended:Wait()
   equipped = true

This means the animation plays, the script waits for the animation to stop playing, then the tool is equipped.

Put the equipped line in between the animation play and ended lines.

   animation:Play()
   equipped = true
   animation.Ended:Wait()

Same with the unequipped section.

The equipped Variable is a Varaible I will need later on the script which doesn’t have anything to do with the Animation, so it can’t be the problem