Gun offered at end of game isn't working the way I want it to

This Gun is custom made by me and is provided as a toy at the Final part of the game. Its a reward for finishing. While testing the game I had no idea that once the Gun is picked up by a player, it is not available for any other player. I want it to be available for everyone. My script is written as below. I don’t know what to do so that the gun stays available for each player who finishes.

I’ve included two videos below showing player1 and player2 that I used while testing. I show player2 with both the gun and the windchime suncatcher at the end of the game. I also show player1 who does not have either because player2 already got them. This is no good to me. I need all players to be able to get those 2 items.
.
Script

script.Parent.Shoot.OnServerEvent:Connect(function(player,LookAt)

local Gun = player.Backpack:FindFirstChild("Gun")or player.Character:FindFirstChild("Gun")

local cframe = Gun.Barrel.CFrame
local bullet = game.ReplicatedStorage.Bullet:Clone()
bullet.Parent = script.Parent
bullet.CFrame = cframe
bullet.Velocity = LookAt*100
local fly = Instance.new("BodyForce", bullet)
fly.Force = Vector3.new(0,bullet:GetMass()*196.2,0)
game.Debris:AddItem(bullet,10)
wait()
bullet.Touched:Connect(function()
	wait(0.25)
	bullet:remove()
end)

end)

Local Script

script.Parent.Activated:Connect(function()
local pos = script.Parent.Parent.Humanoid.TargetPoint
local LookAt = (pos - script.Parent.Parent.Head.Position).Unit
script.Parent.Shoot:FireServer(LookAt)

end)

Bullet Script

local debounce = true
local timebetdamage = 1
script.Parent.Touched:Connect(function(hit)
if debounce == true then
debounce = false
hit.Parent.Humanoid:TakeDamage(20)
debounce = true
end
end)

Gun in workspace

Screenshot player1 and player2

Screenshot Bullet

robloxapp-20210116-0932537.wmv (3.4 MB)

robloxapp-20210116-0933478.wmv (1.8 MB)

I would have the model of a gun sitting at the end and add a touched event to it. When it is touched clone the tool out of Server Storage and put it into the player’s backpack if they do not already have it. Make sure you do a check on the server that the player is close to the gun because if you don’t, an exploiter could tell the server they touched the gun even if they were no where near it.

2 Likes

Thank You, this worked for me.

I’ve done it this way before but it just didn’t dawn on me to do this. Bare with me as I am still learning. Which is why sometimes even though I’ve already done it before its not connecting quite yet for me to do it this way again. :stuck_out_tongue_closed_eyes:

1 Like

No problem! I am glad I could help! :smiley: