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

Why does it throw the error 'not a valid member'?

Asked by 6 years ago

The following code is a Localsript in ReplicatedFirst.

while wait() do
    if ContentProvider.RequestQueueSize == 0 then
        for i = 0, 1, 0.02 do
            Splashscreen.Background.Logo.ImageTransparency = i
            wait()
        end
        wait(1)
        for i = 0, 1, 0.02 do
            Splashscreen.Background.Transparency = i
            wait()
        end
    end
    Splashscreen:Destroy() -- line 19
end

Why does it throw the error...

14:53:00.748 - Background is not a valid member of ScreenGui 14:53:00.751 - Stack Begin 14:53:00.752 - Script 'ReplicatedFirst.SplashscreenScript', Line 19 14:53:00.752 - Stack End

...even though the Frame Background is a child of the ScreenGui called Splashscreen?

1 answer

Log in to vote
0
Answered by 6 years ago

It hasn't replicated yet

The trick with ReplicatedFirst is that there is absolutely no promise that by the time your script is run there will be anything else. The solution? Just use WaitForChild or create the Instances using your script.

0
This fixed all of my ReplicatedFirst scripts xD Thanks shadow7692 69 — 6y
Ad

Answer this question