Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to keep the reference of TextLabels?

Asked by 7 years ago
Edited 7 years ago

I have a DialogGui in the StarterGui, I have 3 TextLabels OutputTooltip, OutputMaterials, txtMaterials, I can see this TextLabels in Roblox Studio, but when I go to the game in the real server, I got this error "OutputMaterials is not valid menber of DialogGui".

I make this script to see what happened

local recipeBook = script.Parent 

local function printChilds(parent)
    for _, child in ipairs(parent:GetChildren ()) do
        print(tostring(parent) .. " contains  " .. tostring(child) .. ".")
        printChilds(child)
    end
end

printChilds(recipeBook)

This is the output in Roblox Studio:

ImageLabel contains Categories.
Categories contains Other.
Other contains Tooltip.
Categories contains Wall.
Wall contains Tooltip.
Categories contains Wedge.
Wedge contains Tooltip.
Categories contains Floor.
Floor contains Tooltip.
ImageLabel contains ScrollingSelections.
ImageLabel contains blueprintsScript.
ImageLabel contains OutputMaterials.
ImageLabel contains txtMaterials.
ImageLabel contains OutputTooltip.

But this is the output in the real server:

ImageLabel contains Categories.
Categories contains Other.
Other contains Tooltip.
Categories contains Wall.
Wall contains Tooltip.
Categories contains Wedge.
Wedge contains Tooltip.
Categories contains Floor.
Floor contains Tooltip
ImageLabel contains ScrollingSelections.
ImageLabel contains blueprintsScript.

As you can see txtMaterials, OutputMaterials,OutputTooltip are missing, I still don't understand what happens, can someone explain? Would it be a good idea to create the TextLabels in code to be able to keep references?

Any help would be appreciated.

0
In an online server, I believe due to latency, scripts sometimes run before all the objects are loaded. If using "WaitForChild" fixes your problem, that's what happened. ex: outputMaterials = ImageLabel:WaitForChild("OutputMaterials") instead of outputMaterials = ImageLabel.OutputMaterials chess123mate 5873 — 7y
0
"WaitForChild" work good, thanks LordSalchipapas 96 — 7y

Answer this question