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 » Scripters
Home Search
 

Re: How does "not" work.

Previous Thread :: Next Thread 
Trfe2000 is not online. 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 is not online. 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 is not online. 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 is not online. 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
nextgenplatform is not online. nextgenplatform
Joined: 27 Feb 2017
Total Posts: 797
20 Sep 2017 05:22 AM
true = true
false = false
not true = false
not false = true
Report Abuse
Scarperino is not online. Scarperino
Joined: 17 Feb 2017
Total Posts: 22
20 Sep 2017 05:42 AM
Just add a username check + id

nothing else lmfao


Report Abuse
ForceCyber is not online. ForceCyber
Joined: 06 May 2015
Total Posts: 1086
20 Sep 2017 05:52 AM
if not player.UserId == 1 then
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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