Script is located in ServerScriptStorage

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(10)
	local pages = ods:GetSortedAsync(false, 10)
	local data = pages:GetCurrentPage()
	updateBoard(game.Workspace.HighScore.TopBlock.SurfaceGui, data) -- change 'game.Workspace.HighScore.TopBlock.SurfaceGui' to where it will be
end

Error in Output ServerScriptService.Script:16: attempt to index local 'ods' (a nil value) I don't know why this dosent work? It is froms Dummiez Leaderboard, and I placed all the scripts in the right spots, but this has an error. Please help

2 comments

0

It might be because the datastore "Scores" doesn't exist yet on the player/server, and so it's trying to get "Scores" when it doesn't exist. This can be completely wrong, since I rarely use saving. Another note is that the problem has nothing to do with ServerScriptStorage; ServerScriptStorage is just another place to put scripts in so they can run.

0

so how could I fix the problem, just have a wait(10) before script?