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: Agh! This code is killing me!

Previous Thread :: Next Thread 
SirHorse is not online. SirHorse
Joined: 12 Mar 2010
Total Posts: 83
23 Nov 2013 12:09 PM
Hi there! I would love a bit of help debugging this little fella:

function isPartInRange(Part)
if Part ~= nil then
Plots = game.Workspace.Plots:GetChildren()
for i = 1, #Plots do
Point1 = Vector3.new(Plots[i].Position.x - Plots[i].Size.x/2, Plots[i].Position.y, Plots[i].Position.z - Plots[i].Size.z/2)
Point2 = Vector3.new(Plots[i].Position.x + Plots[i].Size.x/2, Plots[i].Position.y + 20, Plots[i].Position.z + Plots[i].Size.z/2)
Region = Region3.new(Point1, Point2)
for k, v in pairs(Workspace:FindPartsInRegion3(Region)) do
if v == Part then
return true
end
end
return false
end
end
end

This function is supposed to detect whether a part is within the region of a plot and then return true or false. The bizarre part is that it will have random parts on the block where it returns false. For example I can put blocks around the perimeter but 2 random blocks will not be placed. This code is a but beyond me as I have entered unknown territory. Any help would be appreciated!

Thanks,
SirHorse
Report Abuse
Greendolph is not online. Greendolph
Joined: 07 May 2008
Total Posts: 2543
23 Nov 2013 12:25 PM
Fascinating! :D Have you tried placing print statements throughout the code to display the codes current state? i.e.
"Drawing region from point "..a.." to "..b..
and
"returning true for part " .. part
and such? That may give you some insight on what is going on.
Report Abuse
SirHorse is not online. SirHorse
Joined: 12 Mar 2010
Total Posts: 83
23 Nov 2013 01:30 PM
Thanks for not immediately putting me down :D
I have and its bizarre because it still is not functioning.
Report Abuse
Greendolph is not online. Greendolph
Joined: 07 May 2008
Total Posts: 2543
23 Nov 2013 01:34 PM
Not functioning as in not posting any output for the bricks that don't appear?
Report Abuse
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
23 Nov 2013 02:29 PM
Sir,


You must READ the printed output as well, then logically figure-out why it is printing what it is printing; thus u find the problem.

Another option is to post the debugging code with the print statements; the results; then let someone else figure it out.

People love little self-contained puzzles; like Sudoku..... And r more likely to help; the more info they r given.

Love,
Bri
Report Abuse
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
23 Nov 2013 02:34 PM
Also: Comment your code. And ALWAYS comment all of your 'End's.

If you will notice, job postings for programmers, always state, "...must be able to write maintainable code."

This means code that any-one can read with no fancy "efficient" shorts-cuts; lots of comment at every line; and meaningful variable names.

That's because: Everybody dies, but the code lives-on....

Love,
Bri
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