Trying to make an 'Admin Gui'. In scriptserverservice I have a script that does this:
game.Players.PlayerAdded:connect(function(player) if player.Name == "0mrlight0" or "edward538" then game.StarterGui.Frame.ScreenGui.Button.Visible = true end end)
This dosen't work, it makes the button visible for everyone. The script inside the button does this:
--VARIBLE LIST MM1 = script.Parent.Parent.MM1 Button = script.Parent Button.MouseButton1Down:connect(function() Button.Visible = false MM1.Visible = true end)
When I click the button it doesn't hide or make the next gui show up. Any help?
Haven't tested it, but the errors most likely occur because of several things: * The first error is a comparison error in the following line:
if player.Name == "0mrlight0" or "edward538" then
This happens because you're comparing "player.Name" to a string value, but it won't be able to process the latter comparison. To fix this, we need to add another "player.Name" to the latter option to get the following code:
if player.Name == "0mrlight0" or player.Name == "edward538" then
To note, it is typically better to use "player.UserId", as opposed to "player.Name", just because of the recent name changes.
player.PlayerGui.Frame.ScreenGui.Button.Visible = true
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function() if player.Name == "0mrlight0" or player.Name == "edward538" then player.PlayerGui.Frame.ScreenGui.Button.Visible = true end end) end)
We waited for the character, so that all of the gui's are loaded, and we are able to access it. The reason why it didn't work was because you're trying to address it before it is finished loading, which means that it technically isn't there, which results in an error.
The second method is to use a ":WaitForChild("")" event to wait for all of the assets within it to load. This can be done, like so:
game.Players.PlayerAdded:connect(function(player) if player.Name == "0mrlight0" or player.Name == "edward538" then player:WaitForChild("PlayerGui"):WaitForChild("Frame"):WaitForChild("ScreenGui"):WaitForChild("Button").Visible = true end end)
Once again, I haven't tested it, but it should work, from memory. If it did, feel free to accept it! If it didn't, let me know, and I'll try to fix it.
game.Players.PlayerAdded:connect(function(player) if player.Name == "0mrlight0" or player.Name == "edward538" then --You have to do the same thing for all players player.PlayerGui.Frame.ScreenGui.Button.Visible = true --PlayerGui is where you update the GUI's, StarterGui doesn't update through the player end end)
You're going in the right direction, but you messed up. Just becuase you found the name of the first player player.Name == "0mrlight0"
, doesn't mean your going to find it in the next "edward538"
. You must tell the script what your looking for. In this case it'd be the name of "edward538". player.Name == "edward538"
game.Players.PlayerAdded:connect(function(player) if player.Name == "0mrlight0" or player.Name == "edward538" then player.PlayerGui.Frame.ScreenGui.Button.Visible = true end end)