I have a client animation to equip a gun. I have two animations loaded (animation track) on a ModuleScript (kept in ReplicatedStorage) that has a function to play the animations. One is to equip the gun, and another is to switch over to an idle animation. This works on the client, although to other clients observing this client there’s a delay in between the equip and idle animation. I’m not sure why it is replicating improperly.
ModuleScript func to equip gun:
local isEquipping = false
function DC15EAnimations.Equip(player)
warn("Playing from module")
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local equipAnimation = DC15EEquip
local idleAnimation = DC15EIdle
local equipTrack = animator:LoadAnimation(equipAnimation)
local idleTrack = animator:LoadAnimation(idleAnimation)
equipTrack:Play()
isEquipping = true
-- Event handler for when the equip animation finishes
local function onEquipAnimationFinished()
if isEquipping then
idleTrack:Play()
equipTrack:Stop()
end
end
-- Connect the event handler to the equip animation's stopped event
equipTrack.Stopped:Connect(onEquipAnimationFinished)
end
LocalScript under gun:
-- Equip tool, play animation, sound effects and then display gun in appropriate time
tool.Equipped:Connect(function()
DC15EAnimations.Equip(player)
SoundEffectsModule.EquipGun()
wait(DC15EAnimations.DC15EBufferTime) -- Wait for appropriate time in animation before making gun model visible
for i, v in pairs(tool:GetChildren()) do
if not (v:IsA("LocalScript") or v.Name == "BodyAttach") then
v.Transparency = 0
end
end
end)
I’ve tried to reroute through a server script, so the module is called from the server (from a RemoteEvent from the client) but this only made the situation worse, where even the client itself had the delay.
What client sees:
https://gyazo.com/be9d3a3043611b132c48a6a395d93a01
What other clients see:
https://gyazo.com/aebfe95bdfb1b7be9c059e36d56e5edb
Note: I’m aware that the gun model also loads in at the wrong time to other clients; this is a separate issue I’m aware of and more confident with fixing. For now, I’m only interested in the animation.
Help would be appreciated!