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
10 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!

01If (Game.Workspace.Game1.Players = "1" or "0")
02then function MouseClick()
03 
04 
05-- Ill add a script here that TP's the player to Game 1 and adds 1 value to Game1.Players
06 
07 
08 
09end
10script.Parent.MouseButton1Down:connect(MouseClick)

2 answers

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago
1function MouseClick()
2    wait(0)
3    local numplaying = Game.Workspace.Game1.Players.Value;
4    if numplaying == 0 or numplaying == 1 then
5 
6    end
7end
8script.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 — 10y
Ad
Log in to vote
-2
Answered by
Dr_Doge 100
10 years ago

I think I have found the answer to my problem!

01function MouseClick()
02wait(0)
03 
04 
05if Game.Workspace.Game1.Players==(1)or (0) then
06 
07 
08 
09end
10end
11script.Parent.MouseButton1Down:connect(MouseClick)

PLEASE TELL ME IF I AM WRONG

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

Answer this question