Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a High Score Board?

Hey,

I have found a script for High Score board but it looks like not working, So i made some small changes but still not working.. What does i wrong i cannot found it (It says that there are no "Errors" Non blue lines..

This script going into "ServerScriptService" The "game.Workspace.HighScore.TopBlock.SurfaceGui" is correct into my workspace, Model: HighScore into this: TopBlock into that: SurfaceGui into SurfaceGui: Name1 - Name10 and Score1 - Score10

local ods = game:GetService("DataStoreService"):GetOrderedDataStore("Scores")
function updateBoard(board, data)
	for k,v in pairs(data) do
		local pos = k
		local name = v.key
		local score = v.value
		local dispname = board:findFirstChild("Name"..pos)
		local dispval = board:findFirstChild("Score"..pos)
		dispname.Text = tostring(name)
		dispval.Text = tostring(score)
	end	
end

while true do
	wait(60) -- Updates every 2 minutes
	local pages = ods:GetSortedAsync(false, 10)
	local data = pages:GetCurrentPage()
	updateBoard(game.Workspace.HighScore.TopBlock.SurfaceGui, data) -- change 'game.Workspace.HighScore.TopBlock.SurfaceGui'
end

This script going into "StarterGui" or "Players" --> Its a local script

wait(5)
local player = game.Players.LocalPlayer
while true do
game.Workspace.UploadScore:InvokeServer()
wait(60)-- How long you want to usend
end

This script going into "Workspace" into this script a have a "RemoteFunction" Named: UploadScore

function script.UploadScore.OnServerInvoke(player)
local inv = player:WaitForChild("leaderstats") -- Whatever stats
local score = game:GetService("DataStoreService"):GetOrderedDataStore("TopScores") -- Name of Data Store
score:SetAsync(player.Name, inv:FindFirstChild("Candy").Value) -- What is in the leaderstats
end

Thank you.

1 answer

I realize this was 3 years ago, but in case anyone stumbles upon it, the answer is that in the StarterGui script the following line:

game.Workspace.UploadScore:InvokeServer()

should be:

game.workspace.Script.UploadScore:InvokeServer()

This is because this user places the remotefunction inside the script created in workspace so the localscript in StarterGui was unable to locate it. The "Script" part of the line should be replaced with whatever you named the script you placed in workspace.

This discussion is preserved as it was. New answers, comments, and votes are closed.