Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Please help me with my 1 vs 1 round system?

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

2 answers

✓ Accepted answer

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!

3 comments

0

But picked1 and picked2 could be the same person.

0

Wouldn't that make the game always pick the same players every time unless the server resets? also can you help me with cframes, the make no sense to me LOL

0

yeah sorry i dont know im not that good at scripting

This discussion is preserved as it was. New answers, comments, and votes are closed.