Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Check if an object is a parent of a string value?

Asked by 9 years ago

I'm trying to create a module script that searches** everything ** in the game and check if it has a string value.

Say I have a part that brings up a gui via magnitude. I want that Gui to say whatever is in the string of that object. I could do it manually with one script but it could only be towards that one part. I want to make it so whatever part has a string value in it, it will say what it the string value contains the Gui.

Is it possible to also run scripts with a string? Because what I am creating is an Interact Gui. If the user is close to a certain part, it will bring up [E] to interact If they press E while magnitude is triggered, it will run the string corresponding to that part.

I am clueless if I need tables to operate this or not. Sorry if I did a horrible job at explaining this concept.

I tried something like this.

local function checkProp(o,prop)
 return pcall(function() return o[prop],prop or nil; end)
end -- local didSucceedBool,messageString or propertyValue,propertyUserValue = checkProp(Object, "Property")

local function checkPropTable(o,...)
local props = 0
local tab = {...}
 for i,v in pairs(tab) do
  if checkProp(o,prop) then
   props = props+1
  end
 end
 return props==#tab,o,unpack(tab);
end

Answer this question