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

Help with a Module Script?

local FontLibrary = require(script.Parent:WaitForChild("FontLibrary")) 
local ExtendedTextLabel = require(script.Parent.FontLibrary:WaitForChild("ExtendedTextLabel")) -- ERROR HERE

FontLibrary:LoadFont(338119316)

local label = ExtendedTextLabel.new()
label.Name = "HUDText"
label.Font = "ObelixPro"
label.Text = "HI"
label.FontSize = 36
label.Position = UDim2.new(0,0,0,0)
label.Size = UDim2.new(1,0,0.15,0)
label.TextColor = Color3.new(1,1,1)
label.Parent = script.Parent.MainHUD

FontLibrary is not a valid member of PlayerGui It says FontLibrary is not a member of PlayerGui, when if I go into the players GUI it has it their. Please help

EDIT Requested module experienced an error while loading Error on line 4

1 answer

✓ Accepted answer

Given the circumstances, I'd say the problem is simply trying to index the PlayerGui for an object that hasn't loaded yet.

Try using the WaitForChild method on the PlayerGui to return then 'FontLibrary', like this:

local FontLibrary = script.Parent:WaitForChild("FontLibrary")

-- I also recommend doing the same thing for the "ExtendedTextLabel"
local ExtendedTextLabel = require(FontLibrary:WaitForChild("ExtendedTextLabel")
FontLibrary = require(FontLibrary)

Anything else that would cause an error would be from the code in the module itself. Remember to have a return value inside each module.

If you're still having trouble with it, let me know.

2 comments

0

That just comes up with a new error. I have edited my question with the error that popsup with WaitForChild()

0

Edited. It might be a problem inside your ExtendedTextLabel module.

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