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: Local Parts

Previous Thread :: Next Thread 
C0mmando323 is not online. C0mmando323
Joined: 15 Dec 2012
Total Posts: 394
08 Mar 2014 04:55 PM

Script:

local container = Workspace:FindFirstChild("LocalBin")
if not container then
container = Instance.new("Camera")
container.Name = "LocalBin"
container.Parent = Workspace
end

for i=1,300 do
wait()
ch = math.random(1,5)
if ch == 1 then
local platform = game.ReplicatedStorage:findFirstChild("LargeBlock"):clone()
platform:MoveTo(Vector3.new(math.random(0,512),math.random(0,15),math.random(0,512)))
end
if ch == 2 then
local platform1 = game.ReplicatedStorage:findFirstChild("MediumBlock"):clone()
platform1:MoveTo(Vector3.new(math.random(0,512),math.random(0,15),math.random(0,512)))
end
if ch == 3 then
local platform2 = game.ReplicatedStorage:findFirstChild("SmallBlock"):clone()
platform2:MoveTo(Vector3.new(math.random(0,512),math.random(0,15),math.random(0,512)))
end
if ch == 4 then
local platform3 = game.ReplicatedStorage:findFirstChild("Stairs"):clone()
platform3:MoveTo(Vector3.new(math.random(0,512),math.random(0,15),math.random(0,512)))
end
if ch == 5 then
local platform4 = game.ReplicatedStorage:findFirstChild("Platform"):clone()
platform4:MoveTo(Vector3.new(math.random(0,512),math.random(0,15),math.random(0,512)))
end
end
platform.Parent = container
platform1.Parent = container
platform2.Parent = container
platform3.Parent = container
platform4.Parent = container

Output Error Code:

15:53:56.348 - Players.Player2.PlayerGui.LocalScript:36: attempt to index global 'platform' (a nil value)
15:53:56.350 - Script 'Players.Player2.PlayerGui.LocalScript', Line 36
15:53:56.350 - stack end
Report Abuse
C0mmando323 is not online. C0mmando323
Joined: 15 Dec 2012
Total Posts: 394
08 Mar 2014 05:42 PM
^
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
08 Mar 2014 05:44 PM
platform is out of scope.
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2014 05:44 PM
Yes.
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
08 Mar 2014 05:44 PM
@robo gtfo
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2014 05:45 PM
lol
Report Abuse
C0mmando323 is not online. C0mmando323
Joined: 15 Dec 2012
Total Posts: 394
08 Mar 2014 05:47 PM
It's out of scope?
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
08 Mar 2014 05:50 PM
Yup. local variables have a certain scope.
Basically, a scope is the area in the script where the variable is defined.

A scope is limited to the outermost area where you defined it...
--Scope 0 (Pretty much global)
function
--Scope 0/1
if then
--Scope 0/1/2
for i = 1, 3 do
--Scope 0/1/2/3
while lol do
--Scope 0/1/2/3/4
end
--Scope 0/1/2/3
end
--Scope 0/1/2
end
--Scope 0/1
end
--Scope 0
Report Abuse
C0mmando323 is not online. C0mmando323
Joined: 15 Dec 2012
Total Posts: 394
08 Mar 2014 09:28 PM
Thanks
Report Abuse
C0mmando323 is not online. C0mmando323
Joined: 15 Dec 2012
Total Posts: 394
08 Mar 2014 09:31 PM
Fixed it, thanks again.
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