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

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

Asked by
Foridex 46
6 years ago
Edited 6 years ago

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) <Parent of all Below>

Block -(Frame) <Child of Title>

EerieMusic -(Sound) <Child of Block>

Thump -(Sound) <Child of Block>

MainFrame -(This is the LocalScript) <Child of Block>

Title -(This is the troubled TextLabel thats giving me errors) <Child of Block>

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
0
Try :WaitForChild on lines 1&2 NexanianStudios 91 — 6y
0
game.Players.LocalPlayer never works, always put this in the first line so it does work: repeat wait() until game:GetService("Players").LocalPlayer greatneil80 2647 — 6y

1 answer

Log in to vote
0
Answered by
FazNook 61
6 years ago

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!!

Ad

Answer this question