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

Why does ROBLOX think that the title is not in PlayerGui when it clearly is?

This script is functional is studio but doesn't seem to work correctly in a server.

THIS SCRIPT IS IN A LOCALSCRIPT

Error Code Is: <"Title is not a valid member of Frame">

The structure of the GUI is:

Title -(ScreenGui)

Block -(Frame)

EerieMusic -(Sound)

Thump -(Sound)

MainFrame -(This is the LocalScript)

Title -(This is the troubled TextLabel thats giving me errors)

local found = game.Players.LocalPlayer:FindFirstChild("PlayerGui")
local gui = found:FindFirstChild("Title")

if found then
	if gui then
		gui.Block.EerieMusic:Play()
		for i=1,0,-.01 do
			gui.Block.BackgroundTransparency = i
			gui.Block.Title.TextTransparency = i
			wait()
		end
		gui.Block.EerieMusic:Stop()
		gui.Block.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
		gui.Block.Thump:Play()
	end
end

if gui.Block.Title ~= nil then
	print(gui.Block.Name .. " is failing")
end

2 comments

0

Try :WaitForChild on lines 1&2

0

game.Players.LocalPlayer never works, always put this in the first line so it does work: repeat wait() until game:GetService("Players").LocalPlayer

1 answer

✓ Accepted answer

What you did wrong was that you were trying to findfirstchild when the gui hasnt been loaded onto playergui. The below script should be ready to use:

Script

found = game.Players.LocalPlayer:WaitForChild("PlayerGui")
gui = found:WaitForChild("Title")

if found then
    if gui then
        gui.Block.EerieMusic:Play()
        for i=1,0,-.01 do
            gui.Block.BackgroundTransparency = i
            gui.Block.Title.TextTransparency = i
            wait()
        end
        gui.Block.EerieMusic:Stop()
        gui.Block.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
        gui.Block.Thump:Play()
    end
end

if gui.Block.Title ~= nil then
    print(gui.Block.Name .. " is failing")
end

If this answers your question, make sure to upvote. Thank you!!

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