I’m currently trying to do tool animations but it’s very buggy and doesn’t always replicate smoothly between server and client when just doing them in the tool so I wanna hear how you guys do them mostly?
should I instead handle the animations in a server script and have the local script just fire animations? or is there a way to do tool animations in localplayerscripts/characterscripts?
below is my script any I already know that trying to use .looping doesn’t work properly but when I try to make the functions just play the non looping animations they begin to bug and it still doesn’t play properly serverside
local function playAnimation1()
if not isPlaying then
isPlaying = true
if canFire and canReload then -- Add a condition to check if the player can fire
canFire = false -- Prevent firing until delay is over
canReload = false -- Prevent reloading while firing
local humanoid = game.Players.LocalPlayer.Character.Humanoid
if ammo > 0 then
if track4 then
track4:Stop()
end
if track2 then
track2:Stop()
end
if track3 then
track3:Stop()
end
track1 = humanoid:LoadAnimation(anim1)
track1.Priority = Enum.AnimationPriority.Action
track1.Looped = true
track1:Play()
track1:AdjustSpeed(4 * fireRate)
task.wait(0.07)
gunshotP()
boltcomboP()
while isLooping and isPlaying do
ammo = ammo - 1
if ammo < 0 then
ammo = 0
end
updateAmmoCount()
if ammo == 0 then
gunshotS()
boltcomboS()
stopAnimation1() -- Stop animation when ammo is zero
return
end
task.wait(fireRate)
-- Get the start position of the laser beam
local startPosition = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
-- Fire the LaserFired remote event to notify the server and other clients
local mouse = game.Players.LocalPlayer:GetMouse()
local endPosition = mouse.Hit.p
eventsFolder.WeaponFiredEvent:FireServer(startPosition, endPosition)
playMuzzleEffect()
end
task.wait(fireRate) -- Add a firing delay
canFire = true -- Allow firing again after the delay
else
gunshotS()
boltcomboS()
playAnimation4()
end
task.wait(fireDelay) -- Add a delay before the player can fire again
canReload = true -- Allow reloading after the delay
end
end
end