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

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

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!

9 comments

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.

1

Yeah, shutting down the server is kind of weird. Also you totally abuse the use of comments...

0

@SirNoobly I want to shut down the whole server so the script wont get bugs.

0

What script?

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.

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

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.

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.

0

Errors galore. Learn the basics before you come here.

1 answer

✓ Accepted answer

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

1 comment

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

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