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: cloning from table gives error?

Previous Thread :: Next Thread 
Festivereinhard2 is not online. Festivereinhard2
Joined: 08 Dec 2015
Total Posts: 587
17 Nov 2016 03:49 AM
hi, i have this script that should clone everything in a table, but when i run it it does clone everything, but it also errors. the error is:

Workspace.Regeneration:18: attempt to index local 'p' (a nil value)

the script is:

local regen = {}

for i,v in pairs(game.Workspace:GetChildren()) do --put stuff in backup
if v.ClassName ~= "Terrain" and v.ClassName ~= "Camera" then
table.insert(regen,v)
end
end

wait(3)



parts = 1

for i=1,#regen do --backup everything

local p = regen[parts]:clone()
if p.Name ~= "Regeneration" then
p.Parent = workspace
end
parts = parts+1
end

regen = {} --empty backup table

what did i do wrong?
Report Abuse
Festivereinhard2 is not online. Festivereinhard2
Joined: 08 Dec 2015
Total Posts: 587
17 Nov 2016 08:20 AM
bump
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
17 Nov 2016 08:20 AM
like i said

local p = regen[i]:Clone() *


Report Abuse
Festivereinhard2 is not online. Festivereinhard2
Joined: 08 Dec 2015
Total Posts: 587
17 Nov 2016 08:38 AM
it errored this:

Workspace.Regeneration:16: attempt to index local 'p' (a nil value)

line 16 is the one you just wrote.
Report Abuse
Festivereinhard2 is not online. Festivereinhard2
Joined: 08 Dec 2015
Total Posts: 587
18 Nov 2016 06:37 AM
bump
Report Abuse
HlCOM is not online. HlCOM
Joined: 29 Mar 2009
Total Posts: 3332
18 Nov 2016 06:57 AM
works fine for me
Report Abuse
CloneTrooper1019 is not online. CloneTrooper1019
Joined: 19 Jan 2009
Total Posts: 6227
18 Nov 2016 07:01 AM
local regen = {}

for _,v in pairs(workspace:GetChildren()) do
if not (v:IsA("Camera") or v:IsA("Terrain")) and v.Name ~= "Regeneration" then
table.insert(regen,v:Clone())
end
end

wait(3)

for i = #regen,1,-1 do
local obj = regen[i]
table.remove(regen,i)
obj.Parent = workspace
end


Report Abuse
Festivereinhard2 is not online. Festivereinhard2
Joined: 08 Dec 2015
Total Posts: 587
18 Nov 2016 08:11 AM
clonetrooper, thank you so much!
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