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! 