Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to call a function by using a string name?

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

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!

3 comments

0

edit your question title and put [SOLVED]

0

can i have an example, make a function and call it with string

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

This discussion is preserved as it was. New answers, comments, and votes are closed.