Ad
Log in to vote
0

How to call a function by using a string name?

Asked by 21 days 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 21 days 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 1701 — 20d
0
can i have an example, make a function and call it with string WINDOWS10XPRO 438 — 20d
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 — 19d
Ad

Answer this question