Calling instance function (with colon) from string

Basically, I want to call something like :WaitForChild from a "WaitForChild" string.

I’ve tried calling it from Instance["WaitForChild"], but it returned an error explaining how I needed to call it from a colon instead of a period.

I want to know if it’s possible to do this and if so, how.

Thanks for your time!

I am curious as to why you need to do this. I am unaware of any alternatives of calling the method itself, however I do not know for certain. If you really need this done, could you pass it via a function and check if the string is “WaitForChild”, and act accordingly?

I could, but then I’d have to detect any of all of the methods from all of the classes. As I need support for all classes.

What is the use case of this? Why can you not simply call methods in standard method syntax?

If you have to do it this way…you can just pass Instance as the first argument (then the child’s name):

Instance["WaitForChild"](Instance, childName)
2 Likes

Used one of those Loadstring modules to execute a string.

Here’s the string I used.

[[return function(Self, Varient)
	return game:GetService("]]..string.split(RealInstance:GetFullName(), ".")[1]..[[")]]..tostring(string.gsub(RealInstance:GetFullName(), string.split(RealInstance:GetFullName(), ".")[1], ""))..[[:]]..Index..[[(Varient)
end]]

Sorry for the hassle!

Yes I found that out. Sorry for not getting back sooner!