Could you please show your code for your script? Otherwise, we are not able to help.
local playercount = 0
game.Players.PlayerAdded:Connect(function(player)
for i, players in pairs(game.Players:GetChildren()) do
local plrframe = script.Player:Clone()
plrframe.Parent = script.Parent
plrframe.Username = players
plrframe.DName = game.Players:WaitForChild(players).DisplayName
plrframe.PlayerImage = game.Players:GetUserThumbnailAsync(game.Players:WaitForChild(players).UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
playercount = i
end
end)
game.Players.PlayerRemoving:Connect(function(player)
for i, frames in pairs(script.Parent:GetChildren()) do
frames:Destroy()
end
for i, players in pairs(game.Players:GetChildren()) do
local plrframe = script.Player:Clone()
plrframe.Parent = script.Parent
plrframe.Username = players
plrframe.DName = game.Players:WaitForChild(players).DisplayName
plrframe.PlayerImage = game.Players:GetUserThumbnailAsync(game.Players:WaitForChild(players).UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
playercount = i
end
end)
btw this IS a local script
Using PlayerAdded in a local script will only fire when another person joins the server. So the person who just joined will not have this fired on their client.
that still didnt work (character limit)
Im not exactly sure what you just tried
i just converted the local script into a script, I still used the same code
Oh well in that case you should move the script to serverscriptservice if you haven’t already.
I’m assuming this is meant to change a GUI. If that’s the case, you will need to use a remote event and have it fire to the client when they join. And then from there you can run the for loop through a local script
Sorry, I’m new to this, but could you give me the steps for that? I don’t understand
Here I’ll show what just the PlayerAdded should look like and then maybe you can use it as a blueprint for the PlayerRemoving functon.
First off, create a remote event, and place it in ReplicatedStorage. For now, just call it “Event”
This is in a server script placed in ServerScriptService
game.Players.PlayerAdded:Connect(function(player)
game.ReplicatedStorage.Event:FireAllClients()
end)
And in a local script (preferably where you had it originally just so the pathways match up)
game.ReplicatedStorage.Event.OnClientEvent:Connect(function()
for i, players in pairs(game.Players:GetChildren()) do
local plrframe = script.Player:Clone()
plrframe.Parent = script.Parent
plrframe.Username = players
plrframe.DName = game.Players:WaitForChild(players).DisplayName
plrframe.PlayerImage = game.Players:GetUserThumbnailAsync(game.Players:WaitForChild(players).UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
end
end)
Let me know if this works or if any errors show in the output.
ill try this in a bit (char limit)
Well that didn’t work, and I didn’t get anything about it in the output.
Try adding a print("Test") in the PlayerAdded function and a print("TestLocal") in the OnClientEvent and see if that prints