This script gives NO errors in the output! But it doesn't save the Coins or the Level or the Reward. I've made 2 scripts, one's the Load script and one's the Save script. I'm just starting to use some datastores so it might have alot of errors!
Load script:
levl = game:GetService("DataStoreService"):GetDataStore("LevelTesting")
cahs = game:GetService("DataStoreService"):GetDataStore("CashTesting")
rewa = game:GetService("DataStoreService"):GetDataStore("DRewardTesting")
game.Players.PlayerAdded:connect(function(plr)
local key = "save-"..plr.userId
local stats = Instance.new("Model", plr)
stats.Name = "leaderstats"
local L = Instance.new("IntValue", stats)
L.Name = "Lvl"
local C = Instance.new("IntValue", stats)
C.Name = "Coins"
local r = Instance.new("BoolValue", plr)
r.Name = "Reward"
local saves = {levl:GetAsync(key), cahs:GetAsync(key), rewa:GetAsync(key)}
if saves ~= nil then
L.Value = saves[1] or 1
C.Value = saves[2] or 0
r.Value = saves[3] or false
end
end)
Save script:
levl = game:GetService("DataStoreService"):GetDataStore("LevelTesting")
cahs = game:GetService("DataStoreService"):GetDataStore("CashTesting")
rewa = game:GetService("DataStoreService"):GetDataStore("DRewardTesting")
game.Players.PlayerRemoving:connect(function(plr)
local key = "save-"..plr.userId
levl:SetAsync(key, plr.leaderstats.Lvl.Value)
cahs:SetAsync(key, plr.leaderstas.Lvl.Value)
rewa:SetAsync(key, plr.Reward.Value)
end)
Idk whats wrong after all there's no errors.
both the scripts are NORMAL scripts, not local in ServerScriptService
The save script doesn't seem to me saving OR the load script doesn't seem to be loading.

1 comment
Does the script give errors in-game in the dev-console under server scripts? (Join your game and push F9)