I'm back again, with the same script. This time however, I have a different problem.
For some reason, when both players spawn, it sometimes gives one player two weapons and the other none. What I am trying to do is give one player only one random weapon and the other player another random weapon from the Replicated Storage, not duplicates of one.
I also want to make sure the other player is given one weapon, and not left without one. For some reason though I can't get it working.
--Framework for Random Royale
--With help from scriptinghelpers.org
--//Variables
local rs = game:GetService("ReplicatedStorage")
local maps = rs:FindFirstChild("Maps")
local contestants = game.Players:GetPlayers()
local wep = rs.Weapons
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
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))
print ("Players Spawned")
local backpack = player:FindFirstChild("Backpack")
if backpack then
local weps = wep:GetChildren()
local randomwep = weps[math.random(1, #weps)]
local clonewep = randomwep:Clone()
local randomcontestant = contestants[math.random(1, #contestants)]
clonewep.Parent = randomcontestant.Backpack
print("Random Tool Given")
end
end
end
end
wait(10)
--give weapons
--last man standing
--restart
end
The loop I am talking about starts on line 35, by the way.

1 comment
Why didn't I realize that? Thanks dude, got it working.