Hi, I'm trying to make my game consistantly check if there is more than two players in the game, and if there is, it disables a gui, and enables some scripts, but this doesn't work. I testing it by joining, and then my friend joined, but the gui didn't go away and the scripts didn't enable. Any Help?
Script:
while true do if #game.Players:GetPlayers() >= 2 then local SSS = game.ServerScriptService local Player = game.Players.LocalPlayer local PlayerGui = Player:WaitForChild("PlayerGui") PlayerGui:WaitForChild("TwoPlayers").Enabled = false PlayerGui:WaitForChild("PartOne").Disabled = false SSS:WaitForChild("IntBar").Disabled = false game.Workspace:WaitForChild("Script").Disabled = false wait() end end
If your game is Filtering Enabled then
If your script is a
Script
thenYou can't access **LocalPlayer** or the stuff in **PlayerGui**.end
If it is a
Local Script
thenyou can't access the **ServerScriptService**.end
else
Check if there are errors or not.
end
First of all, are you using a Script or a LocalScript? If you are using a Script, then your problem is that you are trying to use "LocalPlayer" in line 4. You can't access a LocalPlayer with a Script, you must use a LocalScript for that. If you are using a LocalScript, the problem is that in line 3, you are trying to access ServerScriptService. ServerScriptService is not accessible through LocalScript. Try to use another method to access "IntBar", as you are trying to do in line 8. For example, you can place your Script or LocalScript in StarterPlayerScripts, and then access it by finding the player, and then disabling the Script or LocalScript that is in the player. Hope this helps! If it does, please accept my answer.