Remote event save issue

Hi! So, I wanted to make a remote save for my game, but for some reason, it is not working. What happens is, I press a save button and it fires the remote event to save the player’s data. Inside that remote event, I added a small script that checks if the value that it’s about to save is true or false, and accordingly prints a statement. For some reason, it is constantly saving as false, even when I check during game that the value is true. Here is the script for the server, and the local script inside the save button:

Save Button:

local button = script.Parent
local debounce = false
button.MouseButton1Click:Connect(function()
	if not debounce then
		debounce = true
		button.Text = "Saving...Dont Exit!"
		wait(5)
		game.ReplicatedStorage.Save:FireServer()
		button.Text = "Data Saved!"
		wait(2)
		button.Text = "Preparing"
		wait(2)
		button.Text = "Save"
		debounce = false
	end
end)

Note: Everything works as according here, the text changes and the event fires perfectly.

The event handler:

local dss = game:GetService("DataStoreService")
local qs = dss:GetDataStore("Quests")
local ReplicatedStorage = game.ReplicatedStorage

ReplicatedStorage.Save.OnServerEvent:Connect(function(player)
	if player.Quests.Quest1.Value == true then
		qs:SetAsync(player.UserId, player.Quests.Quest1.Value)
		print("Saved true")
	else
		qs:SetAsync(player.UserId, player.Quests.Quest1.Value)
		print("Saved false")
	end
end)

Everything is working, except for the fact that it keeps saving the value as false and printing out false. You might be thinking, maybe the value is false, but it is not as I checked by opening up my player’s inventory in game and seeing. Could anyone tell me what the problem is? Thank you!

Note: Do not worry about the data saving pcalls and things, this is just the basic foundation of the script, I will fix it later, right now, I just needed to know why this isn’t working.

so how exactly are you changing the quest1 value, because it would need to be changed on the server side and not the client

2 Likes

Oh I think you are right! This is my bad, I changed the value straight through the GUI. Thank you so much for clearing that up!! :grinning: