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)
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).