I'm using an basic Data Saving script I'm not getting any errors. But it's not saving the cash is it because where the Money value is being stored? Script:

local DataStoreService = game:GetService("DataStoreService")

local MoneyData = DataStoreService:GetDataStore("MoneyData")

local Players = game:GetService("Players")

game.Players.PlayerAdded:Connect(function(player)

local Money = player.PlayerGui:WaitForChild("MoneyValue").PlayerStat.MoneyValue.Value

local Data

local success, errormessage = pcall(function()

Data = MoneyData:GetAsync(player.UserId.."-Money")

end)

if success then

Money = Data

else

print("DataNotStored")

warn(errormessage)

end

end)

game.Players.PlayerRemoving:Connect(function(player)

local success, errormessage = pcall(function()

MoneyData:SetAsync(player.UserId.."-Money",player.PlayerGui.MoneyValue.PlayerStat.MoneyValue.Value)

end)

if success then

print("DataStored")

else

print("DataNotStored")

warn(errormessage)

end

end)

5 comments

0

use bindtoclose and make sure the data is being given through the server and not the client

0

Also, please use the code block feature. It's there for a reason.

0

This didn't work and Idk there was a code block feature

0

oof I really don't know what the issue is as it says that the data saves successfully

0

I fixed this