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

Why is this only making a Button for the 1st Player that joins? and how to fix it

Asked by 7 years ago

local PlayersScroll = {} sf = script.Parent for _, player in pairs(game.Players:GetPlayers(PlayersScroll)) do if player.Character then local su = Instance.new("TextButton") su.Parent = sf local uid = player.UserId su.Name = player.Name su.Size = UDim2.new(1, 0, 0.04, 0) su.Text = player.Name..":"..uid su.Font = "SourceSansLight" su.FontSize = "Size28" su.TextWrapped = true su.BackgroundColor3 = UDim2.new(115, 115, 115) PlayersScroll[player.Name] = su end end game.Players.PlayerAdded:connect(function(player) if player.Character then local su = Instance.new("TextButton") su.Parent = sf local uid = player.UserId su.Name = player.Name su.Size = UDim2.new(1, 0, 0.04, 0) su.Text = player.Name..":"..uid su.Font = "SourceSansLight" su.FontSize = "Size28" su.TextWrapped = true su.BackgroundColor3 = UDim2.new(115, 115, 115) PlayersScroll[player.Name] = su end end) game.Players.PlayerRemoving:connect(function(player) if PlayersScroll[player.Name] ~= nil then PlayersScroll[player.Name]:Destroy() table.remove(PlayersScroll, player.Name) end end)

Answer this question