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

Is there an easier way to do this?

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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

Ad

Answer this question