You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear! I want to have a dictionary that has connections to functions that are inside a module script.
- What is the issue? Include screenshots / videos if possible!!
this is the server script(no need to worry about the remote event or local script):
local RS = game:GetService("ReplicatedStorage")
local RemoteE = RS:WaitForChild("RemoteEvent")
local M = require(script.M)
local Dic = {
["Yolo"] = M.Yolo(),
["olo"] = M.olo(),
["lol"] = M.lol()
}
RemoteE.OnServerEvent:Connect(function(plr, StringVal)
Dic[StringVal]()
end)
Note: The values given to Remote onServerEvent is all true(meaning its either “Yolo”, “olo”, “lol”).
And this is the module script(just some basic script to show the problem)
local module = {}
module.Yolo = function()
print("Yolooooo!")
end
module.olo = function()
print("oloooow!")
end
module.lol = function()
print("lolololol!")
end
return module
Note: I know doing it
local Dic = {
["Yolo"] = function()
print("Yolooooo!")
end,
["olo"] = function()
print("oloooow!")
end,
["lol"] = function()
print("lolololol!")
end,
}
this way would work but this would make it so function would take a lot of area on my scripts,
so if there is a way for the way i asked to work i would be happy, thank you for looking at my post.