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")
game.Players.PlayerAdded:Connect(function(player)
wait(5)
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")
end
end
end)
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
end
end)
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!