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

How would you add more usernames? [closed]

Asked by 5 years ago

if game.Players.LocalPlayer.Name == "username 1" then

How would I add more usernames?

0
Replace "username" with {"BoogaBoogaHolder123","Username"} Ifigil 4 — 5y
0
Unless you want this to be client-sided, do this in a regular script. DeceptiveCaster 3761 — 5y

Closed as Not Constructive by hiimgoodpack and DeceptiveCaster

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
0
Answered by
pwx 1581 Moderation Voter
5 years ago

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.

Ad
Log in to vote
-1
Answered by
Robowon1 323 Moderation Voter
5 years ago

Use the **or **statement

ex:




if game.Players.LocalPlayer.Name == "username 1" or "username 2" or "username 3" then
0
-1 for "or statement" (it's an OPERATOR), and for not using it correctly and for not using tables programmerHere 371 — 5y