okay so, when making my weapon tool i quickly scripted this.
local eq = false -- unequipped by default
Tool.Equipped:Connect(function()
equipA:Play()
wait(1.1)
eq = true -- marked as equipped after equip finished
idleA:Play()
end)
Tool.Unequipped:Connect(function()
idleA:Stop()
equipA:Stop()
eq = false -- marked as unequipped once again
end)
Tool.Activated:Connect(function()
if eq == false then return end -- end if tool hasn't finished equipping
end)
now after testing i have realised my stupid mistake here. Tool.Equipped doesnât stop after the tool has been unequipped. this equip animation lasts 1.1s, if you re-equip the tool 0.5s into the animation, the old Tool.Equipped function will continue and âeqâ will become true after 0.6s, in the middle of the freshly started animation. losing a braincell trying to figure out a workaroundâŚ
preventing the player from re-equipping by disabling tool bar is not a solution iâm looking for. players should be able to change weapon during the animation. checking IsPlaying of the animation is a option but it does not work very good for me, i need to change the equip time a bit and i end up with choppy animation interactions.
One way is to have an âactiveAnimationâ variable that points to the currently playing animation. Then, check if it is playing before starting any new animations, otherwise wait. This will give you behavior approximately like how Zeppelin Wars does it, where even if you unequip a weapon its reload animation will keep playing, preventing you from equipping and firing another while still reloading.
hi, thanks for your reply.
this indeed fixes eq becoming true despite tool being unequipped, however one problem stays, the one i mentioned in the post.
Tool.Equipped:Connect(function()
equipA:Play()
wait(1.1)
if activeAnim ~= "equip" then return end
eq = true
idleA:Play()
end)
the active animation would probably be set to ânoneâ once unequipped making so that it wonât set the idle and etc. prior to this post i did have a countermeasure for preventing the functionâs continuation, which was checking if tool is a child of the character. but i removed it here to simplify the code, which wasnât probably the smartest thing so my bad.
the real problem is what i mentioned in the post. if you equip the tool again, activeAnim becomes âequipâ and the previous Tool.Equipped can continue after the wait, shortening the second equipâs time. iâm sorry if iâm bad at explaining this.