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

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

Asked by 5 years ago
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

Log in to vote
0
Answered by 5 years ago

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)

Ad

Answer this question