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

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

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

✓ Accepted answer
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.

1 comment

0

Thank you! This worked for me.

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

2 comments

0

Please correct me if I am wrong

0

This is not right. Please remove this answer

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