You are not logged in. Please log in if you wish to participate in all discussions on the website, chat with friends, and use everything we've got to offer.

Click Register below to, well, register. Derp. Enjoy your stay. ;)

If you do not have an account and wish to create one, please follow the link below.

http://www.robloxtoday.net/register

You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

vorenkurn


Good Robloxian
Good Robloxian
Here is a peculiar set of functions I created for making code that will almost never break in game. Basically it works by searching up the object you are looking for every time with a series of gates to make sure the code doesn't error and break. Here is how to use it:

1. Paste this set of code to the beginning of your script:

Code:
debugIndex = {}
function temp(type)
   local debug = Instance.new(type)
   debug.Parent = Workspace
   debug.Name = "debug " .. script.Name .. " " .. type
   debugIndex[#debugIndex + 1] = debug
   return debug
end
function find(path, type, start)
   if start == nil then start = game
   end
   local debug = temp(type)
   local Locate = start
   local a = 1
   for i = 1, #path do
      local temp = Locate:findFirstChild(path[i])
      if temp == nil then
         print("Failed to find " .. path[#path])
         return debug
      else
         Locate = temp
      end
      a = i
   end
   if a == #path then
      debug:Remove()
      return Locate
   else
      print("Failed to find " .. path[#path])
      return debug
   end
end
function cleardebug()
   for i = 1, #debugIndex do
      debugIndex[i]:Remove()
   end
end


2. Search for a value starting at game (as in game.Workspace) like this:

Code:
find({"Workspace","Brick"},"Part")


or starting at another part like this:

Code:
find({"Head","Face"},"Decal",Player)


3. Run this function every so often to get rid of the extra debugs

Code:
cleardebug()


Most average scripters won't need this, but for you few who have huge complex scripts, this could be really helpful in making your place impervious to breaking.

View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum