Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[SOLVED] Currency isn't saving after purchase. Can someone help?

So i have a button and when you click it it changes a value to something else. When i rejoin the game the value is the same as it was before but if i change the value through developer console it does save. Please help!

here is the server script inside the button:

local Player = script.Parent.Parent.Parent.Parent.Parent.Parent
local LS = Player:FindFirstChild("leaderstats")
local Button = script.Parent
local Image = script.Parent.Parent
local CharVal = Player:WaitForChild("CharacterValues"):WaitForChild("Jessica")

Button.MouseButton1Click:Connect(function()
	if CharVal.Value == 1 then
		script.Parent.Equip.Disabled = false
		LS.Character.Value = "Jessica"
		Button.Text = "Equipped"
		
		wait(3)
		script.Parent.Equip.Disabled = true
	elseif CharVal.Value == 0 then
		script.Parent.Purchase.Disabled = false
		CharVal.Value = 1
		LS.Character.Value = "Jessica"
		Button.Text = "Equipped"
		LS.Bucks.Value = LS.Bucks.Value - 300
		
		wait(3)
		script.Parent.Purchase.Disabled = true
	end
end)

1 answer

✓ Accepted answer

You are updating the values on the client when the Datastore is on the server. As far as the server is concerned your value stays the same because it does not replicate over. You will need to use a RemoteEvent in order to replicate it over to the server (in which the datastore will then save that value).

2 comments

0

do i give the currency through the server or local script when using remote event?

0

The server.

This discussion is preserved as it was. New answers, comments, and votes are closed.