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

My members gui is not deleting the TextLabel when someone leaves?

I Have This Members Gui So That When Someone Joins It Creates a TextLabel And The Text Would Have There Name In It And When Someone Left It Would Delete There TextLabel, But When Someone Does Leave The TextLabel Doesn't Get Deleted. Here Is The Script:

local players = game.Players
local left = game.Players.PlayerRemoving
local list = script.Parent.Scroll.Player:Clone()
local find = script.Parent.Scroll.Player
local you = script.Parent.Parent.Parent.Parent.Parent.Name
wait(0.02)
script.Parent.Scroll.Player:Destroy()

function newPlayer()
	for _,target in pairs(players:GetPlayers()) do
	if target.PlayerGui:FindFirstChild('oofer_gang(Beta)') then
		local added = list:Clone()
		added.Parent = script.Parent.Scroll
		added.Text = target.Name
		if target.Name == 'mahid786' then
			if added.Text == 'mahid786' then
				added.Text = 'Nitro7256 [Owner/Creator]'
			end
		end
		if target.Name == 'GameTime_Studio' then
			if added.Text == 'GameTime_Studio' then
				added.Text = 'GameTime_Studio [Developer]'
			end
		end
		
	end
end
end

function leftPlayer()
	for _,target in pairs(players:GetPlayers()) do
		local removed = list:Clone()
		if removed.Text == target.Name then
		removed.Parent = script.Parent.Scroll
		removed.Text = 'Player Left.'
		wait(2.5)
		removed:Destroy()
		end
		end
end

wait()
newPlayer()

game.Players.PlayerAdded:Connect(newPlayer)
game.Players.PlayerRemoving:Connect(leftPlayer)

Can Somebody Help Plz?

5 comments

0

Maybe instead of using list, could you try using find ? (Line32)

0

how would i do that?

0

Edit the script, replace list to find (line 32)

0

nope it didnt work

0

This is messy and hard to understand.

1 answer

I had trouble understanding your code, so here's my example. None of this is decorated, so you'll have to manage this all yourself and make sure it looks good to you.

But this completely works.

local ScreenGui = Instance.new("ScreenGui",game.Players.LocalPlayer.PlayerGui)
local ScrollingFrame = Instance.new("ScrollingFrame",ScreenGui)
local UIListLayout = Instance.new("UIListLayout",ScrollingFrame)
repeat wait() until game.Loaded
local YourOwnTag = Instance.new("TextLabel",ScrollingFrame)
YourOwnTag.Text = game.Players.LocalPlayer.Name
game.Players.PlayerAdded:Connect(function(Player)
	local TextLabel = Instance.new("TextLabel",ScrollingFrame)
	TextLabel.Text = Player.Name
	Player.PlayerRemoving:Connect(function()
		TextLabel:Destroy()
	end)
end)

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