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

LocalScript is saying that a GUI, in the output, that it isn't valid in PlayerGui, help?

local gui = script.Parent.Parent.Parent.ScreenGui.Camaro.Purchased
local chevy = script.Parent.Parent.Chevy
script.Parent.MouseButton1Click:connect(function()
    wait(0.3)
    if gui.Purchased.Value == true then
        chevy.BackgroundTransparency = 0
        chevy.ImageTransparency = 0
        chevy.Purchase.BackgroundTransparency = 0
        chevy.Purchase.TextStrokeTransparency = 0
        chevy.Purchase.TextTransparency = 0
    elseif gui.Purchased.Value == false then
        print("hello")


    end
    end)

I'm trying to access a gui through a 'phone' app as a separate section. It doesn't work as the ScreenGui isn't a 'Valid member of PlayerGui' help?

Chevy = Phone.Chevy

1 answer

✓ Accepted answer

The problem is that the script tries to find the SceenGui right when the player joins, which is when the StarterGuis haven't copied to the player yet.

To maybe fix this, just add a :WaitForChild() here:

local gui = script.Parent.Parent.Parent:WaitForChild("ScreenGui", 10).Camaro.Purchased -- add a waitforchild
local chevy = script.Parent.Parent.Chevy
script.Parent.MouseButton1Click:connect(function()
    wait(0.3)
    if gui.Purchased.Value == true then
        chevy.BackgroundTransparency = 0
        chevy.ImageTransparency = 0
        chevy.Purchase.BackgroundTransparency = 0
        chevy.Purchase.TextStrokeTransparency = 0
        chevy.Purchase.TextTransparency = 0
    elseif gui.Purchased.Value == false then
        print("hello")


    end
    end)

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