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

Why won't this GUI appear but the TextLabel is created?

Asked by 6 years ago

I'm fairly sure this is a problem with things not loaded while the script is running. how do I fix it though?

LocalScript in PlayerGui.MainGui.MainFrame

game.Players.LocalPlayer:WaitForChild("PlayerGui")
local n1 = script.Parent.N1
local n2 = script.Parent.N2
local n3 = script.Parent.N3
local enabled1 = false
local enabled2 = false
local enabled3 = false
workspace.NotifStorage.ChildAdded:Connect(function(child)
    if enabled1 == false then
        enabled1 = true
        n1.Visible = true
        n1.n1Text.Text = child.Text
        wait(5)
        n1.Visible = false
        enabled1 = false
        child:Destroy()
    elseif enabled2 == false then
        enabled2 = true
        n2.Visible = true
        n2.n2Text.Text = child.Text
        wait(5)
        n2.Visible = false
        enabled2 = false
        child:Destroy()
    elseif enabled3 == false then       
        enabled3 = true
        n3.Visible = true
        n3.n3Text.Text = child.Text
        wait(5)
        n3.Visible = false
        enabled3 = false
        child:Destroy()
    end
end)

the textlabel created upon joining does not get destroyed. only if i duplicate it

Script in workspace

local ns = workspace.NotifStorage
game.Players.PlayerAdded:Connect(function(plr)
    plr:WaitForChild("PlayerGui")
    local tl = Instance.new("TextLabel", ns)
    tl.Text = plr.Name.." joined."
end)
game.Players.PlayerRemoving:Connect(function(playerLeft)
    wait(1)
    local tl = Instance.new("TextLabel", ns)
    tl.Text = playerLeft.Name.." left."
end)
game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character.Humanoid.Died:connect(function()
            wait(1)
            local tl = Instance.new("TextLabel", ns)
            tl.Text = character.Name.." died."
        end)
    end)
end)

(the textlabel is used to store a string, don't ask why i didn't use a stringval)

0
I won't ask why you didn't use a StringValue... but why didn't you use a remote event? :p Also, have you tried adding a print "Line #xx was reached!" in some key places in your code to determine if the events are firing, your function is being called, the execution enters one of the if blocks, ext? Finally, in build mode can you manually change n1's Visibility and it shows up? IdiomicLanguage 30 — 6y
0
i have no idea how to use remoteevents; FE is off. If I duplicate the TextLabel, the gui shows up perfectly. It's just upon joining that it doesn't work. I'll try adding prints. creeperhunter76 554 — 6y
0
To perfect game development, you would need FE. It keeps off the exploiters after all and gives you a better chance to work with Remote Events and local scripts better. User#18043 95 — 6y

Answer this question