badfitz99
|
  |
| Joined: 01 May 2010 |
| Total Posts: 5854 |
|
|
| 20 Jun 2014 01:29 PM |
table = {"Player1"} if clicker.Parent.Name == then
-- Scripter of Off-Topic -- |
|
|
| Report Abuse |
|
|
jakej78b
|
  |
| Joined: 09 Mar 2011 |
| Total Posts: 813 |
|
|
| 20 Jun 2014 01:32 PM |
for k,v in pairs(table) do if v == clicker.Parent.Name then --do whatever end end |
|
|
| Report Abuse |
|
|
Locard
|
  |
| Joined: 13 Apr 2014 |
| Total Posts: 3516 |
|
|
| 20 Jun 2014 01:32 PM |
function IsInTable(tab,value) for i,v in ipairs(tab) do if v == value then return true end return false end
Oh, and NEVER name your table 'table'. |
|
|
| Report Abuse |
|
|
jakej78b
|
  |
| Joined: 09 Mar 2011 |
| Total Posts: 813 |
|
|
| 20 Jun 2014 01:35 PM |
| After GLua I'd almost make table.HasValue a function here. (S&I time) |
|
|
| Report Abuse |
|
|
badfitz99
|
  |
| Joined: 01 May 2010 |
| Total Posts: 5854 |
|
|
| 20 Jun 2014 01:37 PM |
@jake
still get denied access and my name is Player1
-- Scripter of Off-Topic -- |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 01:40 PM |
Table ={ "YourName", "Etc" }
Table.Find = function(self,str) if self[str] == nil then return false end return true end
print(Table.Find("YourName"))
-true
I think, not tested |
|
|
| Report Abuse |
|
|
jakej78b
|
  |
| Joined: 09 Mar 2011 |
| Total Posts: 813 |
|
|
| 20 Jun 2014 01:42 PM |
"still get denied access"
What's that supposed to mean? |
|
|
| Report Abuse |
|
|
jakej78b
|
  |
| Joined: 09 Mar 2011 |
| Total Posts: 813 |
|
|
| 20 Jun 2014 01:43 PM |
| Is this with a click detector? If it is the click detectors uses player as it's argument. |
|
|
| Report Abuse |
|
|
badfitz99
|
  |
| Joined: 01 May 2010 |
| Total Posts: 5854 |
|
|
| 20 Jun 2014 01:43 PM |
@jake
local players_allowed = {"Player1", "Player", "badfitz99"} local door1 = script.Parent.Parent.Door1 local door2 = script.Parent.Parent.Door2
script.Parent.ClickDetector.MouseClick:connect(function(clicker) players_allowed.Find = function(self, str) for i = 1,5 do --number of times you want it to move for _, v in pairs(door1:GetChildren()) do v.CFrame = v.CFrame * CFrame.new(0, -1, 0) end end end
end)
function access_denied() print("Denied noob XDDD") end
-- Scripter of Off-Topic -- |
|
|
| Report Abuse |
|
|
jakej78b
|
  |
| Joined: 09 Mar 2011 |
| Total Posts: 813 |
|
|
| 20 Jun 2014 01:44 PM |
local players_allowed = {"Player1", "Player", "badfitz99"} local door1 = script.Parent.Parent.Door1 local door2 = script.Parent.Parent.Door2
function player_allowed(plr) for k,v in pairs(players_allowed) do if v == plr.Name then return true end end end script.Parent.ClickDetector.MouseClick:connect(function(clicker) if player_allowed then for i = 1,5 do --number of times you want it to move for _, v in pairs(door1:GetChildren()) do v.CFrame = v.CFrame * CFrame.new(0, -1, 0) end end end
end)
function access_denied() print("Denied noob XDDD") end |
|
|
| Report Abuse |
|
|
jakej78b
|
  |
| Joined: 09 Mar 2011 |
| Total Posts: 813 |
|
|
| 20 Jun 2014 01:45 PM |
player_allowed(clicker)
Going too fast today. |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 01:45 PM |
Do this a simpler way. Use indexes to search the table faster and in a more basic manner.
local door1 = script.Parent.Parent.Door1 local door2 = script.Parent.Parent.Door2 local players_allowed = { ["Player1"]=true; ['OtherPlayer'] = true; }
script.Parent.ClickDetector.MouseClick:connect(function(clicker) if players_allowed[clicker.Name] then for i = 1,5 do for _, v in pairs(door1:GetChildren()) do v.CFrame = v.CFrame * CFrame.new(0, -1, 0) end end else print("Denied access."); end end)
|
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 01:46 PM |
@jake
player_allowed[clicker.Name] |
|
|
| Report Abuse |
|
|
jakej78b
|
  |
| Joined: 09 Mar 2011 |
| Total Posts: 813 |
|
|
| 20 Jun 2014 01:47 PM |
| Never thought about it in that way. adding the =true might add up thought. Using ; is a bad practice master. |
|
|
| Report Abuse |
|
|
jakej78b
|
  |
| Joined: 09 Mar 2011 |
| Total Posts: 813 |
|
|
| 20 Jun 2014 01:47 PM |
| Nvm, just making my self look like an idiot just use what master said that was a table. |
|
|
| Report Abuse |
|
|
jakej78b
|
  |
| Joined: 09 Mar 2011 |
| Total Posts: 813 |
|
|
| 20 Jun 2014 01:48 PM |
| @island You don't use brackets on a function. |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 01:49 PM |
Y not use my code?
if TABLENAMEHERE.Find("PlayerName") then --open dat door |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 01:50 PM |
@jake
But they are so much prettier
XD
But anyways, you said clicker as the argument for your function, clicker.Name should've been it anywayz |
|
|
| Report Abuse |
|
|
jakej78b
|
  |
| Joined: 09 Mar 2011 |
| Total Posts: 813 |
|
|
| 20 Jun 2014 01:52 PM |
| Actually clicker because inside of the function I used plr.Name to refer to clicker.Name. Good thing I'm not the one looking like an idiot anymore XD |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 01:54 PM |
Btw
function AddFind() for I,v in pairs(getfenv()) do if type(v) == "table" then getfenv()[I].Find = function(self,str) return self[str] end end end end
Table = { "A","B"} T2 = {"C",DD@} AddFind() print(Table.Find("B"),T2.Find("Hello"))
-B nil |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2014 01:55 PM |
Gahhhhhhhh, jake, y u do dis to me q.q
I'm not lookin like n idiot, just didn't feel like lookin at ur function k? |
|
|
| Report Abuse |
|
|
Locard
|
  |
| Joined: 13 Apr 2014 |
| Total Posts: 3516 |
|
|
| 20 Jun 2014 01:57 PM |
When I think of clicker...
"The Last of Us" |
|
|
| Report Abuse |
|
|
jakej78b
|
  |
| Joined: 09 Mar 2011 |
| Total Posts: 813 |
|
|
| 20 Jun 2014 01:57 PM |
The master already solved it, stop bumping and let the guy use his script. :P
(No I'm not referring to myself as the master) |
|
|
| Report Abuse |
|
|