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

Is there an easier way to do this?

this script is supposed to kick you if I don't want you in my game

if game.Players.LocalPlayer.Name == "supercoolguy53" or game.Players.LocalPlayer.Name == "Player" or game.Players.LocalPlayer.Name == "Player1"or game.Players.LocalPlayer.Name == "Player2" or game.Players.LocalPlayer.Name == "Shadow9142" or game.Players.LocalPlayer.Name == "NovusTheory" or game.Players.LocalPlayer.Name == "edenojack" then
	print 'Hello'
else
	game.Players.LocalPlayer:Kick()
end

1 answer

Array

YES! In fact, you can use an array of names that are acceptable to your code, and compare the name with values from the array.

local names = {"supercoolguy52","Players","Player1","Player2","Shadow9142","NovusTheory","edenojack"}

function isGood(name)
for _,v in pairs(names) do
if name== v then
return true;
end
end
return false
end

if isGood(game.Players.LocalPlayer.Name) then
print'Hello'
else
game.Players.LocalPlayer:Kick()
end

I'll be editing to add more information and explanation but this is just my initial answer

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