Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Please help me with my 1 vs 1 round system?

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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!

Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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!

0
But picked1 and picked2 could be the same person. LennyPlayzYT 269 — 4y
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 PNKFALCON1 27 — 4y
0
yeah sorry i dont know im not that good at scripting omgdodogamer 11 — 4y

Answer this question