Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you detect if player enters thats not on a list?

Asked by 10 years ago

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!

1
I have no idea why you'd shut down the server when someone not on the list joins, just kick the player if he/she is not on the list. SirNoobly 165 — 10y
1
Yeah, shutting down the server is kind of weird. Also you totally abuse the use of comments... Perci1 4988 — 10y
0
@SirNoobly I want to shut down the whole server so the script wont get bugs. TroytheDestroyer 75 — 10y
0
What script? SirNoobly 165 — 10y
View all comments (5 more)
0
THE SCRIPT LISTED ABOVE! also, @Perci1 thats what comments are for! and i shut down the server to refresh it from any cheats/exploits a player might add. plus, i'll figure out how to use Datastore soon enough to save my work. TroytheDestroyer 75 — 10y
2
The script has so many things wrong with it... You need to start from the basics. http://wiki.roblox.com/index.php?title=Absolute_beginner%27s_guide_to_scripting SirNoobly 165 — 10y
1
Well then people can just keep joining and joining and making the server shut down so you can't talk to those people in the list. And no, comments are for organization and notes, not for having conversations with yourself... It also makes it very hard to read. Perci1 4988 — 10y
0
It sounds like you're so much better off playing in one of these -- Build mode, A personal server, or a "created place" with saving enabled, that only you can access. This... this just seems utterly inefficient. RoboFrog 400 — 10y
0
Errors galore. Learn the basics before you come here. Tkdriverx 514 — 10y

1 answer

Log in to vote
-3
Answered by 10 years ago

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. :)

https://www.youtube.com/playlist?list=PL8A3AFE78FAF8CF49

0
wow, print isnt written out right, theres no such thing as game.servershutdown, you sound like some newby. Like if my player touches this brick then my player dies end NinjoOnline 1146 — 10y
Ad

Answer this question