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

Works in Studio but not In Game?

I've been creating an intro gui that works perfectly within studio, however when I publish it to the game of its purpose, it breaks down and everything is stuck. What is the cause for this issue? How can I fix it? I've checked internal problems and it does show an error "Play is not a valid member of ScreenGui". I'm also wondering if WaitForChild(child) could be implemented somewhere, but I'm not sure where.

This is the main programming script. Yes I have all configurations and slides within the gui.

local Screen = script.Parent
local Config = Screen.Config
local Player = Screen.Parent.Parent
local Filter = Screen.Filter
local Content = Screen.Content
local Play = Screen.Play

function FilterFade(start,finish,step)
	for i = start,finish,0.03/step do
		Filter.BackgroundTransparency = i
		wait()
	end
	Filter.BackgroundTransparency = finish
end

if not Player:FindFirstChild(Config.TAG_NAME.Value) then
	local tag = Instance.new("IntValue")
	tag.Name = Config.TAG_NAME.Value
	tag.Parent = Player

	Filter.Visible = true
	for _,image in pairs(Content:GetChildren()) do image.Visible = false end
	wait(Config.Padding_Time.Value)
	for _,image in pairs(Content:GetChildren()) do
		image.Visible = true
		FilterFade(0,1,Config.Fade_Time.Value)
		wait(Config.Display_Time.Value)
		FilterFade(1,0,-Config.Fade_Time.Value)
		image.Visible = false
		wait(Config.Display_Time.Value)
	end
	wait(Config.Padding_Time.Value)
	Screen.Background.BackgroundTransparency = 0.7
	Filter.BackgroundTransparency = 0.7
   wait(2)
   script.Parent:remove()
end

1 comment

0

Is this in a Localscript?

1 answer

repeat wait() until script.Parent:FindFirstChild("Play") -- sometimes things may take a while to load, and this script runs immediately, so it will try to find Screen.Play when it's not loaded yet. So this line repeats waiting 1/30th of a second until it finds Play in Screen.
local Screen = script.Parent
local Config = Screen.Config
local Player = Screen.Parent.Parent
local Filter = Screen.Filter
local Content = Screen.Content
local Play = Screen.Play

function FilterFade(start,finish,step)
    for i = start,finish,0.03/step do
        Filter.BackgroundTransparency = i
        wait()
    end
    Filter.BackgroundTransparency = finish
end

if not Player:FindFirstChild(Config.TAG_NAME.Value) then
    local tag = Instance.new("IntValue")
    tag.Name = Config.TAG_NAME.Value
    tag.Parent = Player

    Filter.Visible = true
    for _,image in pairs(Content:GetChildren()) do image.Visible = false end
    wait(Config.Padding_Time.Value)
    for _,image in pairs(Content:GetChildren()) do
        image.Visible = true
        FilterFade(0,1,Config.Fade_Time.Value)
        wait(Config.Display_Time.Value)
        FilterFade(1,0,-Config.Fade_Time.Value)
        image.Visible = false
        wait(Config.Display_Time.Value)
    end
    wait(Config.Padding_Time.Value)
    Screen.Background.BackgroundTransparency = 0.7
    Filter.BackgroundTransparency = 0.7
   wait(2)
   script.Parent:remove()
end

1 comment

0

if it works, then please mark it as an answer. if it doesn't then reply.

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