It's quite simple using the code you currently have. What you are looking for is the event in the Players service named PlayerAdded, which fires every time a player is in the process of joining the game.
Using your existing function, making it run whenever someone joins is pretty simple:
local frame = script.Parent
function update(player)
local text = game:GetService("ServerStorage"):WaitForChild("TextLabel"):Clone()
text.Text = player.Name
text.Parent = frame
end
game:GetService("Players").PlayerAdded:Connect(update)
It's important to use GetService() when referencing any service, as the service may not exist at the time the script runs, may be named differently, etc.
In addition, it's important to use WaitForChild() when getting the TextLabel. When a new server is created, the PlayerAdded event may be fired for the first player before all parts of the game fully load in, and thus the TextLabel might be missing (so you should use WaitForChild).
1 comment
Duplicate of https://scriptinghelpers.org/questions/7018/how-can-i-do-something-to-do-something-when-a-player-joins. Please make sure you search up your problem before asking.