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: for _,v in pairs do(Workspace:GetChildren())

Previous Thread :: Next Thread 
madattak is not online. madattak
Joined: 07 Aug 2008
Total Posts: 2924
27 Nov 2011 11:58 AM
Originally there was no 'do' but it came up with do expected near 'dov'

if script.Parent == Lighting then


for _,v in pairs do(Workspace:GetChildren())
dov:remove()
end

model = Lighting.game
for _,v in pairs do(model:GetChildren())
dov.Parent=Workspace
end


RegenScript:5:syntax error near 'dov'
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
27 Nov 2011 12:05 PM
for _,v in pairs(workspace:children()) do
v:remove()
end
Report Abuse
madattak is not online. madattak
Joined: 07 Aug 2008
Total Posts: 2924
27 Nov 2011 12:29 PM
for _,v in pairs(game.Workspace:children()) do
v:remove()
end

model = Lighting.game
for _,v in pairs(model:GetChildren()) do
v.Parent=Workspace
end


Nothing happens.
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
27 Nov 2011 12:32 PM
model = game.Lighting
game.Workspace:GetChildren()
 Add a for loop some where in the first one.
 Add a for loop in the second one.
Report Abuse
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
27 Nov 2011 12:32 PM
for _,v in pairs(game.Workspace:children()) do
v:remove()
end
model = game.Lighting.game
for _,v in pairs(model:GetChildren()) do
v.Parent=Workspace
end

#don't judge me
Report Abuse
Pyzothon is not online. Pyzothon
Joined: 26 Oct 2011
Total Posts: 822
27 Nov 2011 12:33 PM
for i, v in pairs(game.Workspace:GetChildren()) do
v:Remove()
end

local model = game.Lighting
for i, v in pairs(model:GetChildren()) do
v.Parent = game.Workspace
end

Oh, cry me a babbling brook.
Report Abuse
madattak is not online. madattak
Joined: 07 Aug 2008
Total Posts: 2924
27 Nov 2011 12:34 PM
Lightning.game is correct, game is the model name. But it might be confusing the script. Ill test it out in a mo Got homework to do :(
Report Abuse
Pyzothon is not online. Pyzothon
Joined: 26 Oct 2011
Total Posts: 822
27 Nov 2011 12:39 PM
fro rly?

    for i, v in pairs(game.Workspace:GetChildren()) do
        v:Remove()
    end
    
    local model = game.Lighting.game --It might help to name this something else to avoid future mistakes
    for i, v in pairs(model:GetChildren()) do
        v.Parent = game.Workspace
    end

Oh, cry me a babbling brook.
Report Abuse
madattak is not online. madattak
Joined: 07 Aug 2008
Total Posts: 2924
27 Nov 2011 02:44 PM
still not doing anything.
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
27 Nov 2011 02:46 PM
for k, v in pairs(game.Workspace:GetChildren()) do
v:Remove()
end

game.Lighting.game:Clone.Parent = game.Workspace

I haven't really read much of the thread, but even so...
Report Abuse
Pyzothon is not online. Pyzothon
Joined: 26 Oct 2011
Total Posts: 822
28 Nov 2011 04:22 PM
Wait...

"if script.Parent == Lighting then"

Is this script in Lighting? If so, put it in Workspace. Nothing runs in Lighting.

Oh, cry me a babbling brook.
Report Abuse
madattak is not online. madattak
Joined: 07 Aug 2008
Total Posts: 2924
29 Nov 2011 10:06 AM
Didnt know that. I think I tried some in workspace without the if but not all of them. I put it in lightning because I didnt want the script to delete its self before it finished.
Report Abuse
madattak is not online. madattak
Joined: 07 Aug 2008
Total Posts: 2924
01 Dec 2011 11:32 AM
The scripts working, ROBLOX has rather helpfuly put in a locked object called Terrain in workspace even if you have no Terrain so the script wont worjk because it cant be removed.
I tried this:


for i, v in pairs(game.Workspace:GetChildren()) do
if v.Name == "Terrain" then v.Parent = Workspace

if v.Parent.Name == "Player"
then v.Parent.Humanoid.Health = 0
else
v:Remove()
end
end
end


for i, v in pairs(game.Lighting.thegame:GetChildren()) do
vclone = v:Clone()
vclone.Parent = Workspace
end

But I just get "The Parent property of terrain is locked. WTH ROBLOX!??!!!?!??!?!?!?!?!
Report Abuse
Benjamint is not online. Benjamint
Joined: 18 Aug 2008
Total Posts: 228
01 Dec 2011 11:37 AM
just dont remove terrain instead of removing and putting it back there.
Report Abuse
madattak is not online. madattak
Joined: 07 Aug 2008
Total Posts: 2924
01 Dec 2011 12:55 PM
How do I tell the script to do nothing if its Terrain then?
Report Abuse
madattak is not online. madattak
Joined: 07 Aug 2008
Total Posts: 2924
01 Dec 2011 02:03 PM
I know it sound stupid but if I use 'if v.Name = "Terrain" then return end' It keeps complaing that there is nothing to end for at line one, no matter how any ends Ive got.
Report Abuse
bourlo is not online. bourlo
Joined: 11 Aug 2009
Total Posts: 399
01 Dec 2011 02:37 PM
'if v.Name == "Terrain" then return end'
Report Abuse
Pyzothon is not online. Pyzothon
Joined: 26 Oct 2011
Total Posts: 822
01 Dec 2011 02:42 PM
    for i, v in pairs(game.Workspace:GetChildren()) do
        if v.Name == "Terrain" then
            return
        end
        --[[if v.Parent.Name == "Player" then
                v.Parent.Humanoid.Health = 0 I have brackets around these because these lines do nothing.]]
        v:Remove()
    end
    for i, v in pairs(game.Lighting.thegame:GetChildren()) do
        local vclone = v:Clone()
        vclone.Parent = Workspace
    end
Report Abuse
madattak is not online. madattak
Joined: 07 Aug 2008
Total Posts: 2924
22 Feb 2012 01:23 PM
Newest version:

for i, v in pairs(game.Workspace:GetChildren()) do
if v.ClassName == "Part" or "Fire" or "Smoke" or "Sparkles" or "Script" or "Sound" then
v:Remove()
end
end
end


for i, v in pairs(game.Lighting.thegame:GetChildren()) do
vclone = v:Clone()
vclone.Parent = Workspace
end

Should work but get an error of 'The Parent property of Workspace. is locked'

Report Abuse
juriaan is not online. juriaan
Joined: 25 Nov 2008
Total Posts: 939
22 Feb 2012 02:20 PM
dont = {"Terrain","Workspace"}

function reset()
for i,v in pairs(Game.Workspace:GetChildren()) do
for i = 1,#dont do
if v.Name == dont[i] then
print(v.Name.." couldn't be removed !")
else
v:Destroy()
end
end
end
end

function put()
model = game.Lighting.thegame
model:clone().Parent = game.Workspace
end

Glad to help,
Juriaan
Report Abuse
madattak is not online. madattak
Joined: 07 Aug 2008
Total Posts: 2924
22 Feb 2012 03:01 PM
Thanks jur, but I needed it to start as soon as it enters workspace, and I used the :GetChildren on the model because it needs to be ungroups to work.
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