TextButton text not changing

  1. What do you want to achieve?
    I’m trying to make a spectating system with a list of players to spectate.

  2. What is the issue?
    I am having trouble matching each TextButton’s text to its corresponding player’s name.

My username should appear where you can read “name”:

RobloxScreenShot20231125_151602112

  1. What solutions have you tried so far?
    I’ve tried to change the script a little bit, but I can’t seem to find what’s causing this.

This is the actual script, please have in mind that I am a newbie at this and it could just be a dumb error.

for _, plr in game.Players:GetChildren() do
	local button = game.ReplicatedStorage.buttonmodel:Clone()
	button.Parent = script.Parent
	button.Name = plr.Name
	button.correspondingplr = plr
	button.Text = button.Name
end

game.Players.PlayerAdded:Connect(function(plr)
	local button = game.ReplicatedStorage.buttonmodel:Clone()
	button.Name = plr.Name
	button.correspondingplr = plr
	button.Text = button.Name
	button.Parent = script.Parent
end)

game.Players.PlayerRemoving:Connect(function(plr)
	for _, button in script.Parent:GetChildren() do
		if button:IsA("TextButton") then
			if button.correspondingplr == plr then
				button:Destroy()
			end
		end
	end
end)

Thank you fot the help in advance!

1 Like

Nevermind, I already fixed it. It was, in fact, a dumb error.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.