I want to find out how to make and call a function from a “submenu” inside a module script. This is my module script:
local pLib_actions = {
custom = {
inPurchase = function(player)
-- Show some in purchase Gui (When the purchase prompt appears)
end,
purchased = function(player)
-- Thank the player (This will run when a product is purchased)
end,
closed = function(userId, assetId, isPurchased)
-- Close any in purchase Guis (This will run when the prompt is closed)
end,
},
-- The script goes on
}
return pLib_actions
This is just half of the script, the other half is called “default” and it has the same functions but different codes.
This is how I call it (it’s a server script):
local actionSet = config.actions
if actionSet == "default" then
_G.aS = require(script.Configuration.PurchaseActions).default
else
_G.aS = require(script.Configuration.PurchaseActions).custom
end
_G.aS.inPurchase(player)
This is where I get the actionSet from: (the actionSet in this case is “default”)
local useCustomActions = configFolder.UseCustomActions
function parse(useCustomActions)
if not useCustomActions then
return "default"
else
return "custom"
end
end
local pLib_config = {
actions = parse(useCustomActions),
-- Script goes on
}
return pLib_config
My issue is that the function inside the module script doesn’t get called when I want to call it.
Forgot to mention: I’ve tried many different ways to trigger the function and many different ways to define (make) the function.