Weapon doesn't shoot if player joins

So i am making a FPS game, but the problem is the weapon doesn’t shoot at all if a player joins.
I don’t know what causes it since nothing from the server is connected to this part of the local script in StarterChar scripts.

Here is the script part that controls the shooting:

game:GetService("UserInputService").InputBegan:Connect(function(input) -- PC
	if CharacterAlive then
		if GunEquipped == true then
			if input.UserInputType == Enum.UserInputType.MouseButton1 then

				if CanFire == true then
					if ViewModelLoaded then
						CanFire = false
						local LookVector = cam.CFrame.LookVector
						local camC = cam.CFrame
						local ViewModel = cam:WaitForChild("Viewmodel")
						local GunModel = ViewModel:WaitForChild("Shotgun")
						SoundE:FireServer() --shoot sound
						MainModule.cast(GunModel, LookVector, 30, Damage, player, camC, CH, AnimationsFolder.SReload, ViewModel, CharacterAlive, player.Character) --sends to the module a signal to generate a bullet

						RecoilSpring:shove(Vector3.new(3, math.random(-3, 3), 10))
						coroutine.wrap(function()

							wait(0.2)	

							RecoilSpring:shove(Vector3.new(-2.8, math.random(-2, 2), -10))
						end) ()

						wait(delay)
						CanFire = true
						return
					end

				end
			end
		end
		
	end
end)

I’d recommend putting some print statements in between the some of your if statements to see if you can identify which condition the script is failing to pass.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.