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

Can anyone see the error?

Asked by 9 years ago

I have some code and the until F1 ~= F2 has red under it, Whats wrong?

local list = game.Players:GetPlayers()
            F1 = list[math.random(#list)]
            F2 = list[math.random(#list)]
            repeat if F1 ==F2 then
                F2 = list[math.random(#list)] 
            until F1 ~= F

2` Thats the code, Thanks for the help in advance.

0
Please post the output. bbissell 346 — 9y

3 answers

Log in to vote
1
Answered by
bbissell 346 Moderation Voter
9 years ago

To start off, You have a typo on line 6.

until F1 ~= F

It should be

until F1 ~= F2

Also, you have the If statement in the wrong spot. It should be before the repeat:

local list = game.Players:GetPlayers()
            F1 = list[math.random(#list)]
            F2 = list[math.random(#list)]
            if F1 ==F2 then
                repeat
                F2 = list[math.random(#list)] 
                until F1 ~= F2

Lastly, You forgot to end your if statement.

local list = game.Players:GetPlayers()
            F1 = list[math.random(#list)]
            F2 = list[math.random(#list)]
            if F1 ==F2 then
                repeat
                F2 = list[math.random(#list)] 
                until F1 ~= F2
            end
Ad
Log in to vote
-1
Answered by 9 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

try ~~~~~~~~~~~~~~~~~ repeat F2 = list[math.random(1,#list)] until F1 ~= F2 --Btw im pretty sure your error is because you dont have math.random(1,#list) ~~~~~~~~~~~~~~~~~

Log in to vote
-2
Answered by 9 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

What does it say when you hover your mouse over it?

Really? two thumbs down? Tough community. I was going to answer it once he explained that .-.

0
it said end expected so I added an end and it worked, Thanks for the tip Dstructiod 0 — 9y

Answer this question