Hello, I have a small question regarding module scripts
Config = {
["Text Size"] = UDim2.new(1 / 50, 0, 1 / 5, 0),
["Text Offset"] = UDim2.new(0, 0, -1 / 5, 0),
["Text Speed"] = 10, -- Letters Per Second
["Text Float Duration"] = 1/10,
["Default Tween Information"] = TweenInfo.new(Config["Text Float Duration"], Enum.EasingStyle.Sine,Enum.EasingDirection.Out, 0,false,0),
["Slow Tween Information"] = TweenInfo.new(Config["Text Float Duration"] / 1.5, Enum.EasingStyle.Sine,Enum.EasingDirection.Out, 0,false,0),
["Fast Tween Information"] = TweenInfo.new(Config["Text Float Duration"] * 2, Enum.EasingStyle.Sine,Enum.EasingDirection.Out, 0,false,0),
}
local DialougeSystem = {}
function DialougeSystem.TypeWrite(Text)
local XAxis = 0
local YAxis = 0
for Chars in Text:gmatch(".") do
local Letter = Instance.new("TextLabel")
Letter.Text = Chars
Letter.Size = Config["Text Size"]
Letter.Position = UDim2.new(XAxis * Config["Text Size"].X.Scale, 0, YAxis * Config["Text Size"].Y.Scale, 0)
Letter.Parent = -- Player's GUI would be referred here.
end
end
return DialougeSystem
Basically I have certain properties require variables that a Local Script would normally have. How would I assign those values? do I just have the required variables be dummy variables then update them when thelocalscript requires them?
Yes, you can. Though depending on your use case, it may be better to pass the object you need into the function to prevent errors. But in this context, it should work.
Basically I’m making a module script that’ll manage functions for animating dialouge boxes and text. since the GUIs are in the playergui property and the scritps that requrie this module have those properties defined whilst the module doesn’t, i’m wondering as to how i’d apply the values to the functions that were required from the module script into the local / server script.
While you can use client variables in a modulescript, depending on how you’re using it, it may be better to just pass the object into the function instead. Like this, for example:
Instead of doing this,
function ModuleFunction(Text)
local player = game.Players.LocalPlayer
-- do the dialogue stuff
end
Then you can do this.
function ModuleFunction(text, player)
-- where we pass LocalPlayer into the 'player' parameter
end
And calling the function would instead look like this.
Again, even without doing that, it should work. That’s just a practice you can use in case the variables you’re trying to get may not be reliable or it’s less efficient than just passing it into the function.