|
| 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 |
|
|
| |
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
| |
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
| |
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
| |
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
| |
|
| |
|
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 |
|
|
| |
|
| |
|