Hello! I have a question. If I want to display a Frame on ONE client’s screen, with a text label, and the text of that text label, to be chosen randomly from the code in a ModuleScript, how could I connect that localscript moduleScript? I thought we could do it like this:
In ModuleScript I have code theories and functions. In Script, I will take from ModuleScript using ‘require’ the theories, functions, and what else that ModuleScript has in it. And if it is necessary to send something to a client on the screen that only he can see, for example, maybe that client received a Quest, and I want the quest to be seen only on that client’s screen.
How should I communicate between ModuleScript and localscript? What is the easiest option?
Not sure what you’re asking for exactly but if you want to make LocalScript use Module’s function to choose random text it would look something like this
Module:
-- Module in ReplicatedStorage
local module = {}
function module.GetRandomText()
local possibleTexts = {"Hello!", "Hello there!", "You got a quest!"} -- random options
local chosenText = possibleTexts[math.random(1,#possibleTexts)] -- chooses random option/text
return chosenText -- returns the chosen text to script that used the function
end
return module
and in LocalScript:
-- LocalScript
local module = require(game.ReplicatedStorage.ModuleScript)
local randomText = module.GetRandomText() -- uses module's function to get the random text
print(randomText) -- prints the text that was randomly chosen by module
-- Logic to display the text
I don’t know how your Guis are setup or when the frame needs to display without more context so you should handle that on your part.