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

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

Asked by 10 years ago

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?

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. Perci1 4988 — 10y
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. Thetacah 712 — 10y
0
i don't know how to put it in a lua text box spikeyajay123123 0 — 10y

1 answer

Log in to vote
-1
Answered by 10 years ago

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)
0
You can define two variables in one line with a comma. Thetacah 712 — 10y
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. Perci1 4988 — 10y
Ad

Answer this question