Animation issue with replicating to other clients

Hello! Yesterday I started to work on a gun system, and I realized that for some reason the Animation the gun plays when it is fired, is looped to all of the clients until they move and then it doesn’t play again.
Its kinda of weird.

Here is a video of it:

here is my code for the animation:

--//Functions
local function InsertAnimationToTable()
	for i,v in pairs(script.Parent.Parent.Animations:GetChildren()) do
		table.insert(loadedAnims, v.Name)
	end
end
local function loadAnimations()
	local character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
    local humanoid = character:WaitForChild("Humanoid")
	local animator = humanoid:WaitForChild("Animator")
	
	for i,v in pairs(script.Parent.Parent.Animations:GetChildren()) do
		loadedAnims[v.Name] = animator:LoadAnimation(v)
	end
end

--//Activating
InsertAnimationToTable()
loadAnimations()
GunModel.Equipped:Connect(function()
	GunOut = true
end)
GunModel.Unequipped:Connect(function()
	GunOut = false
end)

conextActionService:BindAction("MouseHold", function(action, state, input)
	if state == Enum.UserInputState.Begin and GunOut == true then
		if CanFire then
			CanFire = false
			loadedAnims["BasicShot"].Looped = false
			loadedAnims["BasicShot"]:Play()
			wait(WaitTime)		CastModule:CastFire(GunModel.Model.Model.Muzzle,Mouse.Hit.p,Configurations.Velocity.Value,Configurations.Damage.Value) -- this num is velocity
			game.ReplicatedStorage.Remotes.BulletReplication:FireServer(GunModel.Model.Model.Muzzle,Mouse.Hit.p,Configurations.Velocity.Value)		
			wait(WaitTime + .4)
			CanFire = true
		end
	end
end, false, Enum.UserInputType.MouseButton1)

If anyone could help me out that would be great! :grinning_face_with_smiling_eyes:

2 Likes

If it only happens once which part is not running?
Try putting prints into each logic path to try and determine where it is not working.

I already have figured out what the issue was

would you care to share what you found in case someone else has a similar problem?

Oh, well what happened is that the animator left the animation looped so it caused it to repeat as you saw.

1 Like