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: for loop won't work correctly

Previous Thread :: Next Thread 
expoundings is online. expoundings
Joined: 02 Feb 2013
Total Posts: 2359
16 Nov 2015 07:28 PM
the function of this piece of code is to load a map but "shoot" lasers at parts as it loads, but for some reason it skips some parts because it thinks it's not a part, still shoots the laser, and moves on, only loading about half the map
the script gives me no errors

local MapContents = game.ServerStorage.Maps[CombinedName]:GetChildren()
for i = 1, #MapContents do
local RandomInstance = math.random(1, #MapContents)
if MapContents[RandomInstance]:IsA("BasePart") then
local Target = MapContents[RandomInstance].Position
local TargetPosition = (Target - Generator.GeneratorPart.Position).unit
local Ray = Ray.new(Generator.GeneratorPart.Position, TargetPosition * 2047)
local hit, position = workspace:FindPartOnRay(Ray)
local Distance = (position - Generator.GeneratorPart.Position).magnitude
local laser = Instance.new("Part", workspace)
laser.Transparency = 0.5
laser.Anchored = true
laser.BrickColor = BrickColor.new("Bright red")
laser.TopSurface = "Smooth"
laser.BottomSurface = "Smooth"
laser.FormFactor = "Custom"
laser.CanCollide = false
laser.Size = Vector3.new(0.35, 0.35, Distance)
laser.CFrame = CFrame.new(position, Generator.GeneratorPart.Position) * CFrame.new(0, 0, -Distance/2)
local ObjectClone = MapContents[RandomInstance]:clone()
ObjectClone.Parent = MapHolder
wait(0.01)
laser:destroy()
else
local NonObjectClone = MapContents[RandomInstance]:clone()
NonObjectClone.Parent = MapHolder
end
end
Report Abuse
expoundings is online. expoundings
Joined: 02 Feb 2013
Total Posts: 2359
16 Nov 2015 07:29 PM
ok nvm i just noticed what's wrong with LOL
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