So basically, there is a goldbar system, where u click it, it gives u a point (franc) It works perfectly fine, but when i try to buy a gun, and it removes 10 Francs from my system, it works, it removes 10, but when i reconnect from the game, the -10 francs, get back into my inventitory as i never bought the AK-47
**ServerScript: **
local DataStore = game:GetService("DataStoreService"):GetDataStore("Francs")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder", plr) --
leaderstats.Name = "leaderstats" --
Francs = Instance.new("IntValue", leaderstats)
Francs.Name = "Francs"
Francs.Value = 0
local key = "plr-"..plr.UserId
local Saved
local success, errorMessage = pcall(function()
Saved = DataStore:GetAsync(key)
end)
if success then
if Saved then
Francs.Value = Saved[1]
else
local ValuesToSave = {Francs.Value}
DataStore:SetAsync(key, ValuesToSave)
end
else
warn(errorMessage)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local key = "plr-"..plr.UserId
local valuesToSave = {Francs.Value}
DataStore:SetAsync(key, valuesToSave)
end)
Local Script (where u buy AK-47)
local player = game.Players.LocalPlayer
local AKremote = game.ReplicatedStorage.weaponsRemotes.AK
script.Parent.MouseButton1Click:Connect(function(click)
if player.leaderstats.Francs.Value >= 10 then
player.leaderstats.Francs.Value = player.leaderstats.Francs.Value - 10
AKremote:FireServer(player)
end
end)

4 comments
I see you are using a remote event. Is that event for removing 10 Francs from the players stats?
umm no, the remote only gives u the weapon
Ahh, you should make it take away the players stats too. If you don't it only happens client side, and your datastore only saves server side data
can u help me with that