Jurok
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 13387 |
|
|
| 11 Dec 2013 01:01 PM |
How do I make it so I can detect if a player that joined the game has it so their name matches a value in a table?
j-frame |
|
|
| Report Abuse |
|
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 11 Dec 2013 01:04 PM |
Not sure if it is correct, but something like this!
names = {"Slicey", "Montoro", "Yvone"}
game.Players:PlayerAdded:connect(function(player) game.Workspace:WaitForChild(player.Name) for i = 1, #names do if game.Players[i].Name == "Username" then -- Stuff end end)
|
|
|
| Report Abuse |
|
|
Jurok
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 13387 |
|
|
| 11 Dec 2013 01:09 PM |
What's the "Username" string for?
j-frame |
|
|
| Report Abuse |
|
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 11 Dec 2013 01:12 PM |
| Basically it goes through the table and check if there is a name in table called "Username" |
|
|
| Report Abuse |
|
|
Jurok
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 13387 |
|
|
| 11 Dec 2013 01:15 PM |
Oh, I should change that, then
Could you explain the following lines, just for review?: - if game.Players[i].Name == "Username" then --(the [i] after players confuses me.] - for i = 1, #names do --(not sure about this either.)
Thanks.
j-frame |
|
|
| Report Abuse |
|
|
Jurok
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 13387 |
|
|
| 11 Dec 2013 01:23 PM |
Also, this doesn't happen to be working.... and I am completely unsure why....
vip = {"1cooldude361"}
game.Players.PlayerAdded:connect(function(player) game.Workspace:WaitForChild(player.Name) for i = 1, #names do if game.Players[i].Name ~= "vip" then charval = name:GetCharacterFromPlayer() copy = game.Lighting.PAMessage:Clone() charval.Parent = copy charval.Parent = Lighting end end end)
j-frame |
|
|
| Report Abuse |
|
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 11 Dec 2013 01:27 PM |
Uhh, I'm not sure if it is Players[i], but I do think it is..
Players[i].Name checks if the player in the table we searched trough with a for defined as i is there.
Example:
Owner = {"CrniOrao"} -- A table of admins for i = 1,#Owner do -- Scrolls through all of the admins if game:GetService("Players"):FindFirstChild(Owner[i]) ~= nil then -- Checks if there is one of the players located in Owner table o=game:GetService("Players"):FindFirstChild(Owner[i]) -- Setting a varibale o.Chatted:connect(function(msg) -- Function that runs if one of the admins talked if string.sub(msg,1,4) == "ban;" then -- If they say ban; p = game.Players:GetChildren() --Get's all the players for i = 1, #p do -- Runs through all the players again just like table. if string.find(p[i].Name,string.sub(msg,5)) then -- Here's the part that you asked for, it basically searches if the name admin said out is the one. table.insert(Banned,p[i].Name)p[i]:remove() --Adds him to a table named "Banned" which is not defined here. ban() -- Runs something, I copied a part of my admin command end end end |
|
|
| Report Abuse |
|
|
Jurok
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 13387 |
|
|
| 11 Dec 2013 01:29 PM |
Thanks, explains it well. But I am still unsure how to make my current script work, I have stated it in a previous post.
j-frame |
|
|
| Report Abuse |
|
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 11 Dec 2013 01:29 PM |
vip = {"1cooldude361"}
game.Players.PlayerAdded:connect(function(player) game.Workspace:WaitForChild(player.Name) for i = 1, #vip do if game:GetService("Players"):FindFirstChild(vip[i]) ~= nil then charval = name:GetCharacterFromPlayer() copy = game.Lighting.PAMessage:Clone() charval.Parent = copy charval.Parent = Lighting end end end) |
|
|
| Report Abuse |
|
|
Jurok
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 13387 |
|
|
| 11 Dec 2013 01:31 PM |
Thank you! And good thing, I believe I understand what you changed, too.
j-frame |
|
|
| Report Abuse |
|
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 11 Dec 2013 01:32 PM |
I changed these:
for i = 1, #vip do if game:GetService("Players"):FindFirstChild(vip[i]) ~= nil then
|
|
|
| Report Abuse |
|
|
Jurok
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 13387 |
|
|
| 11 Dec 2013 01:35 PM |
The script still seems to be stubborn...
j-frame |
|
|
| Report Abuse |
|
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 11 Dec 2013 01:38 PM |
You've probably messed it up in here:
charval = name:GetCharacterFromPlayer() copy = game.Lighting.PAMessage:Clone() charval.Parent = copy charval.Parent = Lighting
So, basically, this is your main function:
vip = {"Jurok"}
game.Players.PlayerAdded:connect(function(player) game.Workspace:WaitForChild(player.Name) for i = 1, #vip do if game:GetService("Players"):FindFirstChild(vip[i]) ~= nil then -- Stuff end end end) |
|
|
| Report Abuse |
|
|
Jurok
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 13387 |
|
|
| 11 Dec 2013 01:40 PM |
It's supposed to execute that code if your name is NOT in the table, that's why I removed my name and altered what you gave me a bit.
j-frame |
|
|
| Report Abuse |
|
|
Jurok
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 13387 |
|
|
| 11 Dec 2013 01:41 PM |
OOOOOH WAIT, now that I mention it I think I know what I did wrong.
j-frame |
|
|
| Report Abuse |
|
|
Jurok
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 13387 |
|
|
| 11 Dec 2013 01:43 PM |
In my code, I used my old argument "name". You're using "player", I think that's the problem. Let me change and see.
j-frame |
|
|
| Report Abuse |
|
|
Jurok
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 13387 |
|
|
| 11 Dec 2013 01:47 PM |
Nope, still doesn't work.
j-frame |
|
|
| Report Abuse |
|
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 11 Dec 2013 01:56 PM |
| Could you post the script you have at the moment? |
|
|
| Report Abuse |
|
|
Jurok
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 13387 |
|
|
| 11 Dec 2013 01:57 PM |
vip = {"1cooldude361"}
game.Players.PlayerAdded:connect(function(player) game.Workspace:WaitForChild(player.Name) for i = 1, #vip do if game.GetService("Players"):FindFirstChild(vip[i]) == nil then charval = player:GetCharacterFromPlayer() copy = game.Lighting.PAMessage:Clone() copy.Parent = charval charval.Parent = game.Lighting end end end)
j-frame |
|
|
| Report Abuse |
|
|
Jurok
|
  |
| Joined: 26 Feb 2012 |
| Total Posts: 13387 |
|
| |
|
|
| 11 Dec 2013 07:11 PM |
vips = {"1cooldude361"}
function IsVip(list,name) local vip = false;
for _,v in next, list do if v == name then vip = true; break; end end
return vip end
game.Players.PlayerAdded:connect(function(player)
if IsVip(vips,player.Name) then local charval = player.Character if charval then local copy = game.Lighting.PAMessage:clone() copy.Parent = charval charval.Parent = game.Lighting end end end)
If you are trying to display a message, this will not work. Please explain the desired result if this does not work. |
|
|
| Report Abuse |
|
|
GGGGG14
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25344 |
|
|
| 11 Dec 2013 07:32 PM |
players = {} special = {"Name1", "Name2"} game.Players.PlayerAdded:connect(function(plr) if plr then table.insert(players, plr.Name) for _, p in pairs(special) do for i = 1, #players do if players[i].Name == p then print("Is in table") end end end end end) |
|
|
| Report Abuse |
|
|