Leaderboard updater not working

My friend tried to make a leaderboard with SurfaceGui

the one we’re gonna talk about is the “Label” part. (the biggest part uses a different script)

Scripts used:

A normal script placed in serverscriptservice
local RE = RS.PosUpdateRE

local DataStoreService = game:GetService("DataStoreService")
local WinsLeaderboard = DataStoreService:GetOrderedDataStore("WinsLeaderboard")

    local playername = player.Name
    local Data = WinsLeaderboard:GetSortedAsync(false, 100)
    local WinsPage = Data:GetCurrentPage()
    for Rank, data in ipairs(WinsPage) do
        local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
        local Name = userName
        if playername == userName then
            local playeruserid = player.UserId
            RE:FireAllClients(playeruserid, Rank)
            print("Data position sent")
A localscript placed in a surfacegui in the "your position" part
local RE = RS.PosUpdateRE
local runplr = game.Players.LocalPlayer
local runplrid = runplr.UserId

RE.OnClientEvent:Connect(function(playerid, pos)
    print("Data received")
    if runplrid == playerid then
        script.Parent.PosNum.Text = "#"..pos

PosNum is the “Label” as showed in the picture above this

The Problem:

  • The server script does send the player’s userid to the remoteevent, but the localscript doesn’t receive anything and it doesn’t shows any errors.

I know its hard to understand but any help replies from you does help us a ton and we appreciate your help!

1 Like

Keep in mind that local scripts can only be ran when placed in specific places.
Check this https://create.roblox.com/docs/reference/engine/classes/LocalScript

Should tell you all the places where local scripts will run.


thank you! this actually works when we placed the localscript to starterplayerscripts