Custom leaderboard is not detecting when a player join

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    When a player joins it adds a label containing their name to my custom leaderboard
  2. What is the issue? Include screenshots / videos if possible!
    It wont detect the player joining and wont add the label containing the player name however will load the current players in the game showing their player labels for a new player joining. Its weird because it detects when a player leaves and will delete their label for the new player joining that can see the current players.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Testing a print to see if its running the remote event
    image


1 Like

I think the problem is in the server’s code. Here is a fix that I think should work:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    game.ReplicatedStorage.PlayerJoined:FireAllClients(player)
    for _, plr in ipairs(Players:GetPlayers()) do
        if player ~= plr then
            game.ReplicatedStorage.PlayerJoined:FireClient(player, plr)
        end
    end
end)

Players.PlayerRemoving:Connect(function(plater)
    game.ReplicatedStorage.PlayerLeft:FireAllClients(player)
end)

I hope this helps!

Why are you using remote events?

You should be able to access the PlayerAdded and PlayerRemoving events from the client.
Instead of having the function exclusive to the connection, have it seperately and call it for every player that is in the game when the player joins, and then once for every player who joins after that.

I’ve tried that but it doesn’t seem to activate in a local script