#Why doesn't this for i,v loop update?

2 messages · Page 1 of 1 (latest)

grizzled rune
#
for i,v in pairs(game.Players:GetPlayers()) do
    local button = script.Playerbutton:Clone()
    button.Text = v.Name
    button.Name = v.Name
    button.Parent = script.Parent.DampeningMF.ScrollingFrame
    
    button.MouseButton1Click:Connect(function()
        if workspace:FindFirstChild(button.Name) then
            button.MouseButton1Click:Connect(function()
                print(button.Name)
                local targetplr = Players[button.Name]
                print(targetplr.Name)
                ReplicatedStorage.Events:WaitForChild("Pressed"):FireServer(plr, targetplr)
            end)
        end
    end)
end
    
#

What I'm trying to do is create a list for all the players that are currently in the server, but whenever someone joins the server after I do, their button doesn't appear in the list