Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Datastore Values Not Saving When Player Leaves?

Asked by 6 years ago

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)
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 Troidit 253 — 6y
0
Oh, I have a separate script for datastores and it worked when I tested free models that give cash. BunnyFilms1 297 — 6y
0
How about try show us the scripts? Your datastore cleary doesn't work. H4X0MSYT 536 — 6y
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 BunnyFilms1 297 — 6y

Answer this question