generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How do I confirm if a player's name is in a table?

Previous Thread :: Next Thread 
xyzqvr is not online. xyzqvr
Joined: 05 Nov 2014
Total Posts: 14
07 Nov 2014 11:04 AM
ex:
speshulplayers = {"xyzqvr"}
game.Players.PlayerAdded:connect(function(p)
name = p.Name:lower()
end)

how do i do it?
Report Abuse
xyzqvr is not online. xyzqvr
Joined: 05 Nov 2014
Total Posts: 14
07 Nov 2014 11:11 AM
bummmmmppp
Report Abuse
DeviousDeviation is not online. DeviousDeviation
Joined: 28 Dec 2010
Total Posts: 9306
07 Nov 2014 11:12 AM
for i, v in pairs(speshulplayers) do
if v == name then
print(name .. " is relly speshul")
end
end

guise i have a siggy
Report Abuse
xyzqvr is not online. xyzqvr
Joined: 05 Nov 2014
Total Posts: 14
07 Nov 2014 11:19 AM
dont work ;_;
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
07 Nov 2014 11:20 AM
v.Name*
Report Abuse
xyzqvr is not online. xyzqvr
Joined: 05 Nov 2014
Total Posts: 14
07 Nov 2014 11:22 AM
speshulplayers = {"xyzqvr", "Player"}
game.Players.PlayerAdded:connect(
function(p)
for i, v in pairs(speshulplayers) do
print("Comparing "..v.Name.." and "..p.Name)
if v:lower() == name:lower() then
print(name .. " is relly speshul")
script.AdminGui:Clone().Parent = p.PlayerGui
end
end
end
)

12:21:30.413 - Workspace.Script:6: attempt to concatenate field 'Name' (a nil value)
12:21:30.413 - Stack Begin
12:21:30.414 - Script 'Workspace.Script', Line 6
12:21:30.414 - Stack End

wtf name is a string value and it's not nil -_-
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
07 Nov 2014 11:27 AM
It's just v...
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
07 Nov 2014 11:31 AM
^ reffered to me?

for i, v in pairs(speshulplayers) do
if v == name then
print(name .. " is relly speshul")
end
end


so basically

A player == a string

?

we need the name..
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
07 Nov 2014 11:33 AM
Except for that v is already a string because of the table it came from :P
Report Abuse
DeviousDeviation is not online. DeviousDeviation
Joined: 28 Dec 2010
Total Posts: 9306
07 Nov 2014 11:36 AM
local speshulplayers = {"xyzqvr"}

game.Players.PlayerAdded:connect(function(player)
local name = string.sub(player.Name)
for i, v in pairs(speshulplayers) do
if v == name then
print(name .. " is relly speshul")
end
end
end)

guise i have a siggy
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
07 Nov 2014 11:36 AM
Oh, I thought that des guy (forgot name sowwy :p) ment he needed to get the players, forgot we talked about tables lol
Report Abuse
xyzqvr is not online. xyzqvr
Joined: 05 Nov 2014
Total Posts: 14
07 Nov 2014 11:40 AM
thanks elunate
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
07 Nov 2014 01:22 PM
Its more efficent to use a dictionary table though
local whiteList = {
["128GB"] = true;
[1] = true;
} --Don't put quotes if its a userId

local blackList = {
[261] = true;
["noob"] = true;
}

game.Players.PlayerAdded:connect(function(player)
if blackList[player.userId] or blackList[player.Name] and (player.userId ~= game.CreatorId) then
player:kick()
elseif whiteList[player.userId] or whiteList[player.Name] or (player.userId == game.CreatorId) then
player.Chatted:connect(function(input)
print(input)
end)
end
end)
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
07 Nov 2014 01:32 PM
Or, if you're using my helper library

speshulplayers = enum{"A player", "Some other player", ["SomeKey"] = "eLunate"}

print(speshulplayers["A player"]) --> A player
print(speshulplayers[2]) --> Some other player
print(speshulplayers.SomeKey) --> eLunate
print(speshulplayers.eLunate) --> eLunate
print(speshulplayers[3]) --> eLunate
print(#speshulplayers) --> 3 (Compared to 2, which a normal table would give you)

Also works remarkably fine with ipairs hehe
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image