Same script, but this should be the last kink to work out. So whenever the character spawns it is supposed to give each one a random weapon, but never the same one. Sometimes it gives two players the same weapon and another player no weapon! I can assume a way to solve this is by using tables, but I need more training with those. So can anyone help me?
--Framework for Random Royale
--With help from scriptinghelpers.org and Hadschi
--//Variables
local rs = game:GetService("ReplicatedStorage")
local maps = rs:FindFirstChild("Maps")
local contestants = game.Players:GetPlayers()
local gamewep = rs:FindFirstChild("GameWep")
local mapholder = workspace.MapHolder
--//Timing
local intermission = 15 --change to 30 after testing
local roundtime = 180 --maybe lengthen or shorten
local endtime = 10 --maybe 5 seconds
--//Weapon System
local folderclone = gamewep:Clone()
folderclone.Name = "NewGameWep"
folderclone.Parent = rs
local folderchildren = folderclone:GetChildren()
while true do
mapholder:ClearAllChildren()
wait(intermission)
local contestants = game.Players:GetPlayers()
local allmaps = maps:GetChildren()
local newmap = allmaps[math.random(1,#allmaps)]
local clonemap = newmap:Clone()
clonemap.Parent = workspace.MapHolder
print ("Map Loaded")
wait(2)
local spawns = clonemap:WaitForChild("Spawns")
for _,player in pairs(game.Players:GetPlayers()) do
if player and player.character then
local spawnplace = spawns.Spawn
local torso = player.Character:WaitForChild("Torso")
if torso then
torso.CFrame = CFrame.new(spawnplace.Position + Vector3.new(0,3,0))
local checktag = Instance.new("StringValue")
checktag.Name = "CheckTag"
checktag.Parent = player.Character
print ("Players Spawned")
local backpack = player:FindFirstChild("Backpack")
local randomwep = folderchildren[math.random(1,#folderchildren)]
randomwep.Parent = player.Backpack
end
end
end
--last man standing
local timer = roundtime
while timer > 0 do
wait(1)
timer = timer - 1
activecontestants = {}
for _,player in pairs(contestants) do
if player then
local character = player.Character
if character then
local checktag = character:FindFirstChild("CheckTag")
local humanoid = character:FindFirstChild("Humanoid")
if checktag and humanoid and humanoid.Health > 0 then
table.insert(activecontestants, player)
end
end
end
end
if #activecontestants <=1 then
break
end
end
folderclone:destroy()
print ("Game End")
--restart
end
Giving players the weapons starts at about line 39. Any and all help will be appreciated!

2 comments
you could add a function so that when a player receives a weapon it checks the weapons in all other players and then based on math.random fires the respective client to change their weapon? By the way is this server side?
Yes, this is serverside.