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)