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

[ANSWERED] How do you use an "If" line in a GUI button script to only alow 2 people in Game1 ?

Asked by
Dr_Doge 100
9 years ago

I need help with this minigame script. This is a script in a GUI button. Im my workspace I have An arena called Game1 and It contains a NumberValue Called Players. I want to make it so that only 2 players can be in Game1 at a time. Thank You for reading my problem!

If (Game.Workspace.Game1.Players = "1" or "0")
then function MouseClick()


-- Ill add a script here that TP's the player to Game 1 and adds 1 value to Game1.Players



end
script.Parent.MouseButton1Down:connect(MouseClick)


2 answers

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago
function MouseClick()
    wait(0)
    local numplaying = Game.Workspace.Game1.Players.Value;
    if numplaying == 0 or numplaying == 1 then

    end
end
script.Parent.MouseButton1Down:connect(MouseClick)

We cannot say if something == 1 or 2 then. We have to be explicit in both comparisons: if something == 1 or something == 2.

In addition, you need to use the Value of your NumberValue, not the NumberValue itself.

0
Thank you! This worked for me. Dr_Doge 100 — 9y
Ad
Log in to vote
-2
Answered by
Dr_Doge 100
9 years ago

I think I have found the answer to my problem!



function MouseClick() wait(0) if Game.Workspace.Game1.Players==(1)or (0) then end end script.Parent.MouseButton1Down:connect(MouseClick)

PLEASE TELL ME IF I AM WRONG

0
Please correct me if I am wrong Dr_Doge 100 — 9y
0
This is not right. Please remove this answer BlueTaslem 18071 — 9y

Answer this question