ok, so I'm making this private test game and I want to know how to shutdown the server if the player that enters is not on a list, Because if a bunch of people that were strangers came in, the place would not be private anymore. so heres my code:
print 'Certain Permission Script Loading...' -- alert the people that this script is loading local servershutdown = game.Players:ClearAllChildren() -- VERY useful so I don't have to type so much... local creatorid = game.CreatorId -- might be useful later local ListOfPermissions = "TroytheDestroyer, DadatheDestroyer, Troy2006, Troyother" -- people who can enter without being kicked local nonacess = -- what do I put here? I want the script to shut the server down if a player -- enters that does not belong to the List of Permissions. local playeradded = game.Players.PlayerAdded -- to shorten the typing like line 2. servershutvalue = Instance.new("BoolValue") -- Control the server if it's going to shut down servershutvalue.Value = false -- So it doesn't kick everyone as soon as they enter if servershutvalue.Value == true then -- if its true that a player entered that is not allowed then shut down the whole server game.Players:ClearAllChildren() -- it wouldn't allow me to put servershutdown so i just did that end -- to close this part while true do -- to do it over so if a player joins it will analyze the player. game.Players.PlayerAdded = -- it gave me an error message saying "Expected '=' got 'if'" so i put = there. if playeradded == ListOfPermissions then -- OH NOES DO THIS SO IT WONT SHUT DOWN ON THE ALLOWED PLAYERS!!!!! servershutvalue = false -- so it won't shutdown if playeradded -- this is my point where i'm stuck.. I don't know how to shutdown the server if the player is not allowed -- I don't know how to say not equal so look at line 5 to help me. end -- thanks for reading this.
please answer me! thanks for reading!
Why not consider making the server a personal server through the configuration settings? Eh, regardless... here's some help with you script.
print (Certain Permission Script Loading...) -- alert the people that this script is loading servershutdown = Players:ClearAllChildren() -- VERY useful so I don't have to type so much... allowed = {"TroytheDestroyer", "DadatheDestroyer", "Troy2006", " Troyother"} -- people who can enter without being kicked function PlayerAdded(player) if player.Name == allowed then print (Everything is going to be alright!) else player.Name -= allowed then game.servershutdown end end game.Players.PlayerAdded:connect(PlayerAdded)
This shoulder workout better than your last script, sorry for the dramatic changes. Also, I'd recommend watching pighead10's tutorials on Youtube as they will help you a great deal of alot on your knowledge of Roblox Lua. :)