So im trying to give one person a weapon, but its giving everyone a weapon when i start a test server in studio
local choose = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())]
if choose:FindFirstChild("Backpack") then
game.ReplicatedStorage.Luger:Clone().Parent = choose.Backpack;
end
EDIT
thats not all of it though,
local players = game.Players:GetPlayers()
local using = false
while math.huge do
wait(5)
using = false
if using == false then
using = true
if (game.Players.NumPlayers <= 1) then -- This will be the less complicated 'invite more' part
using = true
game.StarterGui.gui.LocalScript.Event:Fire()
else
if(game.Players.NumPlayers >= 2) then
wait(5)
target = CFrame.new(0, 50, 0) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its torso exists
if player.Character and player.Character:FindFirstChild("Torso") then
--add an offset of 5 for each character
player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
wait()
local choose = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())]
if choose:FindFirstChild("Backpack") then
game.ReplicatedStorage.Luger:Clone().Parent = choose.Backpack;
end
end
end
end
end
end
end
EDIT 2
It seems to be giving out a weapon per player, and sometimes gives someones weapon to another person

3 comments
no, ill give it all
(im still working on it so it doesnt delete the weapons yet)
Thanks! Im new to looping a lot at things at once