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

How to run a function by a variable name?

Asked by 6 years ago

I am making a admin script and I want it so were if you chat it see you used : and it knows that the rest might be the command, so the command can be searched through a list of function and if its a function then it could do something like

runfunction(Variable)

0
if variable == "Whatever" then casper123123123 357 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
if variable == "whatver" then

elseif variable3 == "whatevr2" then



elseif variable4 == "whtevr2" then
end
Ad
Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago

You'll need to use string.sub(), of a function of the string manipulation functions. You can find it here : http://wiki.roblox.com/index.php?title=Global_namespace/String_manipulation

game.Players.ChildAdded:Connect(function(player)
    player.Chatted:Connect(function(msg)
        if msg:sub(1,1) == ':' then
            runfunction(msg:sub(2))
        end
    end)
end)

Answer this question