I'm trying to help my son with Roblox Studio. I'm an app developer but have never used Roblox before.
I'm stuck being able to call a function from another file...
We have a file called InsRankHandler
under ServerScriptService
. It has a Frame
with some Labels
and I can change the text in the labels just fine when using the game.Players.PlayerAdded:Connect
callback.
We now want to change the labels text from an Adonis
function.
I've added a function to the InsRankHandler
file like this:
local InsRankHandler = {}
function InsRankHandler.setText(text)
local clone = script.Rank:Clone()
clone.Frame.Name1.Text = text
end
return InsRankHandler
Then I try to call it from the Adonis
function like this:
local fun = require(game.ServerScriptService.InsRankHandler)
fun.setText("something");
but this gives me an error of an incorrect require.
If I print
like this:
print(game.ServerScriptService.InsRankHandler);
it correctly shows InsRankHandler
so I can't figure out what is wrong. I know it's probably some really obvious syntax error.
EDIT -----
I've added a ModuleScript
under ServerScriptService
that contains this:
local module = {}
function module.setText(text)
print("setText:")
end
return module
Then in the Adonis
function (that is also under ServerScriptService
) I try to access it like this:
local fun = require(game.ServerScriptService.module)
or like this:
local fun2 = require(game.ServerScriptService.ModuleScript.module)
but both give me the error: module is not a valid member of...