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

Can complex functions be returned?

This is the local script:

local P = Events.GeneralFunction:InvokeServer("ButtonP", Cloak)

Which travels to the EventHandler script in ServerScriptService

Events.GeneralFunction.OnServerInvoke = function(Plr, Request, Data)
    if Request == "ButtonP" then
	    local Power = powerData[plrData["Buttons"][Data]]
	    return Power
    end
end

"powerData" is a module script which holds the super power data such as cooldown, but I would like to also store the function that the power does:

local module = {
	["Cloak"] = {
		["CoolDown"] = 5;
		["Activated"] = function(Plr)
			print(Plr)
			end
	}
}

However, if i were to below in a local script:

P["Activated"](Plr)

it doesn't seem to work or print the player as set by the function, is what I'm doing actually possible?

2 comments

0

more information please, what is P?

0

P is stands for power, I just abbreviated it so exploiters will have a slightly harder time looking through the scripts

1 answer

In order to call the function, you'd do

local module = require(module)
module["Cloak"]:["Activated"](Plr)

1 comment

0

thats not how methods work, but ok

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