Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hello robloxians!
- you probably are searching for a way to test if things exist and some people have ideas on how to do so and they don't work.
- well, I made a function to test for objects, their className, and any other property.
- here is the code:
- --Name
- _G.exist = function(location, item)
- local children = location:GetChildren()
- local Return = nil
- for i = 1, #children do
- if children[i].Name == item then
- Return = true
- end
- if i == #children then
- if not Return == true then
- Return = false
- end
- end
- end
- return Return
- end
- --className
- _G.existsOfClassName = function(location, item)
- local children = location:GetChildren()
- local Return = nil
- for i = 1, #children do
- if children[i].Name == item then
- Return = true
- end
- if i == #children then
- if not Return == true then
- Return = false
- end
- end
- end
- return Return
- end
- --Any property
- _G.existsOfProperty = function(location, typeValue, typeName)
- local children = location:GetChildren()
- local Return = nil
- for i = 1, #children do
- if children[i][typeName] == typeValue then
- Return = true
- end
- if i == #children then
- if not Return == true then
- Return = false
- end
- end
- end
- return Return
- end
- --[[And remember:
- that the property for the existOfProperty function's 3rd parameter (the typeName parameter) has to be
- in quotes.
- ,
- to use _G. [ function name ] () Instead of [ function name ] () for example:
- _G.existsOfClassName
- Instead of:
- existsOfClassName.
- ,
- that you only have to put all this code in a script and then you don't have to put it in every script
- you made just use _G. [ function name ] .
- ]]
- .
- If there are any errors or this code didn't work please reply that on this thread
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement