Hello. I am currently scripting a speedrun leaderboard but I have run into a problem with remote events. I have a server script for the leaderboard and a local script with the timer information. Currently, the server script is firing a remote event to which the local script receives and supposedly should return a string, however, it returns nil.
local function readabletime(timer)
return string.format("%02d:%05.2f", timer/min, timer%min)
end
Readabletimer.OnClientInvoke = readabletime
Snippet of leaderboard code from server script:
for a, b in ipairs(top) do
local userid = b.key
local points = b.value
local username = "[Failed To Load]"
local s, e = pcall(function()
username = game.Players:GetNameFromUserIdAsync(userid)
end)
if not s then
warn("Error getting name for "..userid..". Error: "..e)
end
local image = game.Players:GetUserThumbnailAsync(userid, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150)
table.insert(data, {username, points, image})
ui.Parent = script
scrollingframe:ClearAllChildren()
ui.Parent = scrollingframe
for number, d in pairs(data) do
local name = d[1]
local image = d[3]
local color = Color3.new(1,1,1)
if number == 1 then
color = Color3.new(1,1,0)
elseif number == 2 then
color = Color3.new(0.9,0.9,0.9)
elseif number == 3 then
color = Color3.fromRGB(166, 112, 0)
end
local new = sample:Clone()
new.Name = name
new.LayoutOrder = tonumber(number)
new.ImageLabel.Image = image
new.ImageLabel.Place.Text = number
new.ImageLabel.Place.TextColor3 = color
new.PName.Text = name
new.Value.Text = game.ReplicatedStorage.ReadableTimer:InvokeClient(d[2]/1000)
new.Value.TextColor3 = color
new.PName.TextColor3 = color
new.Parent = scrollingframe
end
wait()
scrollingframe.CanvasSize = UDim2.new(0,0,0,ui.AbsoluteContentSize.Y)
end