#uhh, this datastore isn't saying it saved?? :O
Is this a common thing that happens? I made this data-store entirely by myself and it did not say; "Data Saved", nor did it warn an errormessage.
Also the remote event where i fire it is too long to write in, and casually people that work in scripting helpers prefer small neat code.
And also what happens when i fire the remote event is;
I made a shop script and this script is supposed to save the already bought items. It gets fired everytime the player buys a new item.
local rm = game.ReplicatedStorage.ShopRemotes.ShopInitializer
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DataStore")
local SavedItems = {}
rm.OnServerEvent:Connect(function(plr, name, x)
table.insert(SavedItems, x)
pcall(function()
local RetrievedData = DataStore:GetAsync("Player_"..plr.UserId)
if RetrievedData then
for _, v in pairs(RetrievedData) do
v.alreadybought = true
end
else
local Item = game.ReplicatedStorage.Tools:FindFirstChild(name):Clone()
Item.Parent = plr.Backpack
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value - x.price
end
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
local sucess, errormessage = pcall(function()
DataStore:SetAsync("Player_"..plr.UserId, SavedItems)
end)
if sucess then
print("Datastore Worked")
else
print("Datastore didn't work, but that doesn't mean I'm bad :D")
warn(errormessage)
end
end)

4 comments
idk how to solve this, but im posting this to give you a notification of hope
Does this RemoteEvent allow players to buy whatever they want without even checking if they're able to? Don't trust the client. Also, the Cash is able to go under zero. Does PlayerRemoving even run by the way?
'Don't trust the client'. @brokenVectors , I think you need to add more to the explanation as to why. Basically, exploiters can exploit the client, however, they cannot exploit the server. They can send remote events.
You saved the items but you never did a GetAsync in your script. Maybe that is why it is not working?