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 » Scripting Helpers
Home Search
 

Re: How to use "nil"?

Previous Thread :: Next Thread 
robotmega is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
19 Jun 2012 10:15 AM
So i got this script

waittime = 60
removetime = 60

while true do
wait(waittime)
a=game.Lighting.Zombie:clone()
a.Position = script.Parent.Position
wait(removetime)
a:remove()
end



When u kill the zombie with a gun, he gets removed, so if u kill him, the script breaks.
I need to fix it. Someone help me?
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
19 Jun 2012 10:17 AM
You never parented Zombie to Workspace.

And I would use Destroy().
Report Abuse
robotmega is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
19 Jun 2012 10:26 AM
Miz, i was lazy and i made this 90% replica of the script. The real script works, but i need to know "nil"
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
19 Jun 2012 10:31 AM
Then why not just ask what nil is :o

Nil means non existence, nothing. Mostly, you use it to check if something is in Workspace or not but it's especially used in outputs.
Report Abuse
Uuvinu is not online. Uuvinu
Joined: 19 Apr 2012
Total Posts: 2206
19 Jun 2012 10:32 AM
nil means nothing essentially.

Someone will have a more accurate definition.

Parent = nil means you put the parent in nothing.
It doesn't remove so you can still modify it, but it's parented in nothing.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
19 Jun 2012 10:33 AM
If you parent something to nil, it's like saying Remove(). Which is pretty much deprecated.
Report Abuse
Uuvinu is not online. Uuvinu
Joined: 19 Apr 2012
Total Posts: 2206
19 Jun 2012 10:34 AM
:Remove() and parenting to nil isn't the same.

model.Parent = nil
model.Parent = workspace
-- models parent is workspace

model:Remove()
model.Parent = workspace
-- generates an error saying model is nil

model = nil is like :Remove()
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
19 Jun 2012 10:38 AM
I meant when using them it isn't fully removed, just locked. That's what I meant by like.
Report Abuse
robotmega is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
19 Jun 2012 10:49 AM
dude can you just fix my script? D: please ur my hero :3
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
19 Jun 2012 10:50 AM
I told you what's wrong. You didn't parent it to Workspace. Parent it to Workspace.
Report Abuse
Uuvinu is not online. Uuvinu
Joined: 19 Apr 2012
Total Posts: 2206
19 Jun 2012 10:51 AM
local waittime = 60
local removetime = 60

while true do
wait(waittime)
local a = game.Lighting.Zombie:clone()
a.Position = script.Parent.Position
a.Parent = game.Workspace
a:MakeJoints()
wait(removetime)
a:Destroy()
end
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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