My Pistol isn't working

Hello, I was making a pistol for my game. And, when I activate the tool, It doesn’t work, and when I checked my output, there wasn’t any errors.

Here’s the script:

local bulletscript = game.ReplicatedStorage.BulletDMG

local debounce = false

local tool = script.Parent.Parent

local bp = script.Parent.Parent.BulletPart

local sound = script.Parent.GunShot

local bullet = game.ReplicatedStorage.Bullet

game.Players.PlayerAdded:Connect(function(plr)
	script.Parent.Parent.Activated:Connect(function()
		if not debounce then
			local mouse = plr:GetMouse()
            local bclone = bullet:Clone()  
			bclone.Parent = workspace
			bulletscript:Clone().Parent = bclone
			bclone.Position = mouse.Target.Position
			bclone.Anchored = true
			sound:Play()
			debounce = true
			if debounce then
				wait(5)
				debounce = false
			end
		end
	end)
end)
1 Like

The PlayerAdded event won’t fire because the script will start running after the player joined the game. Remove that event and instead use a client → server communication system

Like a local script? I don’t understand what you mean.

Instances tree:
Tool
→ Script
→ LocalScript
→ RemoteEvent

Script:

remoteEvent.OnServerEvent:Connect(function(player, otherParameters)
    --Create the bullet and damage the player
end)

LocalScript

tool.Activated:Connect(function()
    remoteEvent:FireServer(parametersExceptThePlayer)
end)