I am having a problem with my money saving. I am using FE and the datastore works but my script that deducts money does not. When the user clicks it, it deducts the money but the money does not save when the user leaves the game. Why does it not save?

local Player = game.Players.LocalPlayer
local PlayerStats = Player:WaitForChild('leaderstats'):WaitForChild('Money')

script.Parent.MouseButton1Click:Connect(function()
	if PlayerStats.Value > script.Parent.Parent.Parent.Price.Value - 1 then
		PlayerStats.Value = PlayerStats.Value - script.Parent.Parent.Parent.Price.Value
				script.Parent.Parent.Parent.Enabled = false
	end
	
end)

4 comments

0

It doesn't look like you're actually attempting to save the values to the DataStoreService. Leaderboard values do not save on their own. I would suggest you read up on saving to datastores. http://wiki.roblox.com/index.php?title=Data_store

0

Oh, I have a separate script for datastores and it worked when I tested free models that give cash.

0

How about try show us the scripts? Your datastore cleary doesn't work.

0

I have figured out the issue, I am using a local script rather than a server script but I don't know how to get a player from a server script