Iv'e been trying for days to make a system for my game where the game picks 2 random people and puts them in a 1v1 in an arena with a timer. All the sources I've found for how to do this are either buggy or just flat out dont work. I also want a spectate only mode, so I'm using 4 teams:
Fighting1 Fighting2 Spectating SpecOnly
I'm newer to scripting, usually only build stuff and model, but I've been needing to make this for days.
Please link me a source for this or send a script
Hi PNKFALCON1!
omgdodogamer's response could work, however, picked1 and picked2 might be the same person. This script will ensure that picked1 ~= picked2 and it will teleport the players. (Base of code from omgdodogamer :D)
local players = game.Players:GetChildren() local picked1 local picked2 local TPPos = CFrame.new(0,0,0) --Set CFrame here while true do wait(3) if #players >= 3 then picked1 = players[math.random(1, #players)] picked2 = players[math.random(1, #players)] while picked1 == picked2 do picked2 = players[math.random(1, #players)] --This will keep on rerolling until picked1 is not picked2 end print(picked1, picked2) picked1.Character:SetPrimaryPartCFrame(TPPos + Vector3.new(0,3,0)) --Ensures the player will not be stuck in a wall picked2.Character:SetPrimaryPartCFrame(TPPos + Vector3.new(15,3,0)) --Ensures the player will not teleport right next to picked1 end end
If this works, please don't forget to accept my answer!
i cannot answer your full question (because i dont know how to make a spectating system) but for the picking random players i think you would do
while true do wait(3) local players = game.Players:GetChildren() print(#players) if #players >= 3 then local picked1 = players[math.random(1, #players)] local picked2 = players[math.random(1, #players)] -- then you just make picked1 and picked2 teleport to some arena or something to fight
hope this helped!