I create this script , and put it in the "ServerScript Service But when i change the Value Cash1, it wont save it. I call the Cash from a localscript in Screen Gui When i start the Server again the Cash.Value is 0 ....
so i call the file
local player = game.Players.LocalPlayer
local levelpoint = player.leaderstats.Cash1
levelpoint.Value = levelpoint.Value +5
this is the DAtastore script
local DataStoreServer = game:GetService("DataStoreService") local myDataStore = DataStoreServer:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player
local Cash1 = Instance.new("IntValue")
Cash1.Name = "Cash1"
Cash1.Parent = leaderstats
local data
local succes, errormessage = pcall(function()
data = myDataStore:GetAsync(player.UserId.."Cash1")
end)
if succes then
Cash1.Value = data
else
print("there was an error ")
warn(errormessage)
end
end) game.Players.PlayerRemoving:Connect(function(player) local succes , errormessage = pcall(function() myDataStore:SetAsync(player.UserId.."Cash1",player.leaderstats.Cash1.Value)
end)
if succes then
print("player data succesfully saved")
warn(errormessage)
end
end)

5 comments
I've already done it ....
Good!
did not help
need a publish game! in Roblox Studio click 'Game Settings', in 'Options' enable Studio Access to API Services (click ON)! um...
ok, and how i can change the cash from scrip ? call the leaderstat from localscript ?