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

How to call a function by using a string name?

Asked by 1 year ago

Hi, I'll spare you the details of why I need to do what I need to do but the issue is quite simple. Lets say I have a string such as "GetFullName" and I want to call "GetFullName" as though it were a function (basically as Instance:GetFullName() ) I've tried doing Instance:"string", Instance["string"], and Instance:["string"] but it doesn't seem to work. Anyone know how I could do this?

1 answer

Log in to vote
1
Answered by 1 year ago

Found the solution thanks to a friend! Incase you're some random person looking up how to do this exact thing heres how:

You can actually define a function in a pretty crazy way Lets say you want to do what I did, you would define the function as

local func = instance["GetFullName"]

That'll actually return the unique identifier for a function (in this case 0x3df93cb10337308e) Any time you need to call it you can then just call it like any function with func(parameter)

You might have to change the way the function is defined depending on your scenario, but this should work!

0
edit your question title and put [SOLVED] T3_MasterGamer 2189 — 1y
0
can i have an example, make a function and call it with string WINDOWS10XPRO 438 — 1y
0
you could also do an while true do loop which contains a condition : if sting.match("Your Text", TheText) then FunctionWhenTexted() inside of a local script Fouxelefr 7 — 1y
Ad

Answer this question