So when the datastore script tries to get the Cubes value from the Datastore, it gives me an error saying "ServerScriptService.Datastore:9: Attempted to index number with number" which I have no idea on how to fix.
Datastore script:
local datastore = game:GetService("DataStoreService"):GetDataStore("SaveData") game.Players.PlayerAdded:Connect(function(plr) wait() local plrid = "id_"..plr.UserId local save1 = plr.leaderstats.Cubes local GetSaved = datastore:GetAsync(plrid) if GetSaved then save1.Value = GetSaved[0] else local NumSave = {save1.Value} datastore:GetAsync(plrid,NumSave) end end) game.Players.PlayerRemoving:Connect(function(plr) datastore:SetAsync("id_"..plr.UserId,plr.leaderstats.Cubes.Value) end)
Leaderstats script:
local Players = game:GetService("Players") local function leaderboardSetup(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local cubesmade = Instance.new("IntValue") cubesmade.Name = "Cubes" cubesmade.Value = 0 cubesmade.Parent = leaderstats end Players.PlayerAdded:Connect(leaderboardSetup)
GetSaved[1] and local GetSaved = datastore:GetAsync("id_"..plrid)