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

How do i automaticly place players into a random team when they join/round starting?

I have tried this but i don't think i have done it properly.

Blue = 0 Red = 0

game.Players.PlayerAdded:connect(function(team)

if Blue = 0 then do if Red= 0 then do

Blue = 1

if Blue = 1 then do If Red = 0 then do

and i kept doing that till i had all of it covered but it didn't work so i just deleted the script.

Does anyone have any ideas of how i could fix it?

3 comments

0

I would like to point out that it is never a good idea to delete nonfunctional code. As for your specific error, I suggest you review some of the basics on the wiki.

0

I'd have to agree with Perci1. Also, when you write code here for us, I highly suggest you put it in a lua textbox.

0

i don't know how to put it in a lua text box

1 answer

✓ Accepted answer

Just so you know, you haven't specified that you want a player to be in a specific team at a certain value, you haven't even told the script to do anything. Additionally, don't define two variables in the same line, it doesn't work.

Here's a start to your script, I'm not writing the whole thing for you, but here's a bit to start with:


blue = game.Teams.Blue --This defines the blue team. Make sure a blue team exists!
red = game.Teams.Red --This defines the red team. Make sure a red team exists!

function onJoin(player)
	--define your function below


end

game.Players.PlayerAdded:connect(onJoin)

2 comments

0

You can define two variables in one line with a comma.

0

You can define two variable in one line like so; 'a=1 b=2'. Adding a comma, 'a=1, b=2' results in an error. It is, however, generally better to separate your variables into multiple lines for readability purposes.

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