Trfe2000
|
  |
| Joined: 23 Apr 2016 |
| Total Posts: 73 |
|
|
| 20 Sep 2017 01:32 AM |
I want to make a door that only I can walk though, it work when I remove "not" which makes everyone enter but myself. But of course I only want myself to enter. Just it doesn't work anymore. Am I using the "not" wrong? This is my script:
function ot(hit) if hit.Parent ~= nil then local player = game.Players:playerFromCharacter(hit.Parent) if player ~= nil then local h = hit.Parent:FindFirstChild("Humanoid") if h ~= nil then if h.Health ~= 0 then if player.UserId == not 1 then -- 1 is the ID (my own got tags) player:kick("THIS GAME IS UNDERCONSTRUCTION, TRY AGAIN LATER") end end end end end end
script.Parent.Touched:connect(ot) |
|
|
| Report Abuse |
|
|
sglrty
|
  |
| Joined: 03 Jan 2017 |
| Total Posts: 336 |
|
|
| 20 Sep 2017 01:41 AM |
ok so you can basically do either
if variable == false then end
or
if not variable then end
|
|
|
| Report Abuse |
|
|
gmatch
|
  |
| Joined: 21 May 2014 |
| Total Posts: 1173 |
|
|
| 20 Sep 2017 02:33 AM |
Yes, you're using "not" incorrectly. "not" is usually used after the "if" in the if statement.
It could be seen like this as you can't do: if plr:FindFirstChild("Backpack") == false then -- stuff end
but rather:
if not plr:FindFirstChild("Backpack") then -- stuff end |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 20 Sep 2017 03:04 AM |
That is because FindFirstChild returns nil, not false.
@OP
You are already using the ~= operator 4 times previously... |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2017 05:22 AM |
true = true false = false not true = false not false = true |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2017 05:42 AM |
Just add a username check + id
nothing else lmfao
|
|
|
| Report Abuse |
|
|
|
| 20 Sep 2017 05:52 AM |
| if not player.UserId == 1 then |
|
|
| Report Abuse |
|
|