if game.Players.LocalPlayer.Name == "username 1" then
How would I add more usernames?
if game.Players.LocalPlayer.Name == "username 1" then
How would I add more usernames?
Okay, your best bet is to use an array storing all the usernames. That way you don't have to keep using 'or' since it's an operator.
I am not entirely sure why you are using a LocalScript for your checks since this can be abused by exploiters, but it's your personal preference I guess.
Players = game:GetService('Players')
Player = Players.LocalPlayer
local usernameList = {'bob123', 'username', 'robloxadminguy123'} -- Store all the usernames here.
function checkUsername(Player)
local nameString = Player.Name
for _,v in pairs(usernameList) do -- loop through the table
if string.lower(v) == string.lower(nameString) then -- use string.lower for cap sensitivity
return true -- if username found, return true
end
end
return false -- otherwise no username found, false
end
if checkUsername(Player) then
-- rest of code here
end -- end the if statement
A breakdown of the code would be, the array stores the data and the function loops through that data to check if a string matches the data, if it does then it'll pass the if statement.
Use the **or **statement
ex:
if game.Players.LocalPlayer.Name == "username 1" or "username 2" or "username 3" then
-1 for "or statement" (it's an OPERATOR), and for not using it correctly and for not using tables
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Replace "username" with {"BoogaBoogaHolder123","Username"}
Unless you want this to be client-sided, do this in a regular script.