Jinxy
|
  |
| Joined: 04 Aug 2007 |
| Total Posts: 18317 |
|
|
| 10 Jul 2011 03:42 PM |
So, if I wanted to make a door that only certain people could go through, I COULD make the statement read: ---- if model.Name == (Player or Player or Player) then script.Parent.Cancollide = false. end ---
|
|
|
| Report Abuse |
|
|
zeke505
|
  |
| Joined: 26 May 2008 |
| Total Posts: 15765 |
|
|
| 10 Jul 2011 03:45 PM |
No,
if model.Name == "dsdfjsdf" or model.Name == "fsdfjk" or model.Name == "BOB" then |
|
|
| Report Abuse |
|
|
Jinxy
|
  |
| Joined: 04 Aug 2007 |
| Total Posts: 18317 |
|
|
| 10 Jul 2011 03:45 PM |
| oh. ._. Thanks, that made a bit more sense... |
|
|
| Report Abuse |
|
|
killjoy37
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 2821 |
|
|
| 10 Jul 2011 03:49 PM |
You never aked a question there, but I'll help you out.
on = false function onTouch(hit) if hit.Parent:findFirstChild("Humanoid") ~= nil then if on == false then on = true if hit.Parent.Name == "name" or hit.Parent.Name == "name" or hit.Parent == "name" then script.Parent.Transparency = 0.5 script.Parent.CanCollide = false wait(1) script.Parent.Transparency = 0 script.Parent.CanCollide = true else hit.Parent.Humanoid.Health = 0 end wait(0.5) on = false end end end script.Parent.Touched:connect(onTouch)
Try that, if there are any errors tell me. |
|
|
| Report Abuse |
|
|
Jinxy
|
  |
| Joined: 04 Aug 2007 |
| Total Posts: 18317 |
|
|
| 10 Jul 2011 03:52 PM |
| I wasn't asking for a script, I was asking for affirmation if my way would work... |
|
|
| Report Abuse |
|
|
Shobobo99
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 5754 |
|
|
| 10 Jul 2011 03:53 PM |
Here is a more simple way to avoid all the "or"s. Have a table of all the people's names you want to allow like this:
local Allowed = {NAME = 1, ANOTHERNAME = 1, YETANOTHERNAME = 1}
if Allowed[hit.Parent.Name] then print("yus") --do your stuff end
|
|
|
| Report Abuse |
|
|
killjoy37
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 2821 |
|
|
| 10 Jul 2011 03:55 PM |
| Your way would work if Model was a variable called hit.Parent. |
|
|
| Report Abuse |
|
|
Shobobo99
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 5754 |
|
|
| 10 Jul 2011 03:56 PM |
| My way would work for any string. |
|
|
| Report Abuse |
|
|
Jinxy
|
  |
| Joined: 04 Aug 2007 |
| Total Posts: 18317 |
|
|
| 10 Jul 2011 03:56 PM |
So, --- local Allowed = {JINXY = 1, Shobobo99 = 1, Zeke501 = 1 --- means that those names all have the same value, 1, and since they all have the same value, that makes them allowed. |
|
|
| Report Abuse |
|
|
Shobobo99
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 5754 |
|
|
| 10 Jul 2011 03:59 PM |
| No, what the name equals to does not really matter. What happens when you say "JINXY = 1" is you are making a key "JINXY" for the value 1. This means that you can use that key to be able to check if a name, for example a players name exists in that table. |
|
|
| Report Abuse |
|
|
Jinxy
|
  |
| Joined: 04 Aug 2007 |
| Total Posts: 18317 |
|
|
| 10 Jul 2011 04:04 PM |
What I meant was, since JINXY = 1, Shobob99 = 1, and Zeke505 = 1, then, JINXY = Shobob99 = Zeke505 = 1. |
|
|
| Report Abuse |
|
|
Shobobo99
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 5754 |
|
|
| 10 Jul 2011 04:08 PM |
When you say (with the table already defined):
if Allowed["JINXY"] then --stuff end
You are checking if it can find the key "JINXY" in the table, and if so then return true and if it does not find it, it will return false. The value of "JINXY" isnt being used but you CAN use it to set LEVELS of permission. For example:
Allowed = {Shobobo99 = 1, Zeke505 = 2, JINXY = 3}
if Allowed[Name] == 3 then print("Level three access accepted!") end
This is not the only use for it but an example. |
|
|
| Report Abuse |
|
|
Jinxy
|
  |
| Joined: 04 Aug 2007 |
| Total Posts: 18317 |
|
|
| 10 Jul 2011 04:10 PM |
| Ohh... It's much easier then creating multiple admin doors that you delete the names off of that cannot access beyond that point, if you set "access" levels.... |
|
|
| Report Abuse |
|
|