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: Script stops at the 'for' function?

Previous Thread :: Next Thread 
smunkey is not online. smunkey
Joined: 17 Dec 2011
Total Posts: 342
14 Jul 2014 09:19 PM
Right after it prints "2" the script won't run.

function onClicked()

print "1"

local g = game.Lighting.pbasic.Chest:clone()
g.Parent = game.Players.LocalPlayer
local C = g:GetChildren()

print "2"

for i=1, #C do
if C[i].className == "Part" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.CFrame)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle

print "3"

end
local Y = Instance.new("Weld")
Y.Part0 = game.Players.LocalPlayer.Chest -- HM? This is real or mistake?
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0-- Why is this end here?

print "4"

local h = g:GetChildren()

end

for a = 1, #h do
if h[a].className == "Part" then
h[a].Anchored = false
h[a].CanCollide = false
end
end
end

script.Parent.MouseButton1Click:connect(onClicked)
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
14 Jul 2014 09:23 PM
Right before/after print'2' put
print(#C)
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
14 Jul 2014 09:23 PM
You're missing an end somewhere

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
14 Jul 2014 09:26 PM
Nop
It wouldn't print anything besides
"Error in script: end expected near"...
Report Abuse
smunkey is not online. smunkey
Joined: 17 Dec 2011
Total Posts: 342
14 Jul 2014 09:29 PM
It doesn't do any more or less when i had the 'print (#C)' and I couldn't find a place that needed an 'end'.
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
14 Jul 2014 09:31 PM
You're doing it wrong.
If there is no output after 2 is printed, your for loop is looking like this
"for i = 1,0 do" thus it'll never run.
From this was can assume #C = 0
if you put the print(#C) where I told you it'd either print 0 which confirms my theory or it'd print another number.
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
14 Jul 2014 09:33 PM
You're still missing an end

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
14 Jul 2014 09:34 PM
Disregard my previous comment, I forgot how to numbers

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
smunkey is not online. smunkey
Joined: 17 Dec 2011
Total Posts: 342
14 Jul 2014 09:34 PM
I missed the error since I was just looking for a number, anyways #C = 0
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
14 Jul 2014 09:36 PM
That means that game.Lighting.pbasic.Chest has no descendants.
Report Abuse
smunkey is not online. smunkey
Joined: 17 Dec 2011
Total Posts: 342
14 Jul 2014 09:58 PM
I fixed that, but still stops at the same area.


function onClicked()

print "1"

local g = game.Lighting.pbasic.Chest:clone()
g.Parent = game.Players.LocalPlayer
local C = g.Parent:GetChildren()

print "2"

for i=1, #C do
if C[i].className == "Part" then -- Should I remove this and/or the line above
-- it?
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.CFrame)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle

print "3"

end
local Y = Instance.new("Weld")
Y.Part0 = game.Players.LocalPlayer.Torso -- HM? This is real or mistake?
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0

print "4"

local h = g:GetChildren()

end

for a = 1, #h do
if h[a].className == "Part" then
h[a].Anchored = false
h[a].CanCollide = false
end
end
end

script.Parent.MouseButton1Click:connect(onClicked)
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
14 Jul 2014 10:13 PM
No output besides the prints?
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
14 Jul 2014 10:13 PM
for is a loop, not a function.
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
14 Jul 2014 10:15 PM
Who called it a function?
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