How to save a boolvalue to a player so its saved when they rejoin

I’m not entirely sure that this is the way to go at this but i think it is. So lets say for example i have an npc that has a quest, if the player completes the quest it would set a boolvalue to true upon completion so the player couldn’t redo the quest, how could i do this?

I’ve tried looking on yt and on devforums all day but i can’t seem to find a solution to it, if someone could just tell me how to go at the saving i could do the entire system :p.

With a boolean value is the best way to save quests or bought items in a shop.
My friend and I came up with a datastore script a while ago that is designed to never fail.

local datastore = game:GetService("DataStoreService"):GetDataStore("put your own name here") -- the datastore

local playerdata = {}

local function getData(plr) -- gets the data
	local boolval = playerdata[plr.UserId]
	local data
	
	repeat -- repeats until getting the data from the datastore is successful
		local success = pcall(function()
			data = datastore:GetAsync(plr.UserId)
		end)
	until
	success
	
	if data then -- if there is data the bool value will be changed
		boolval.Value = data
	end
end

local function setData(plr) -- sets/saves the data
	local boolval = playerdata[plr.UserId]
	
	repeat -- repeats until the data is successfully saved
		local success = pcall(function()
			datastore:SetAsync(plr.UserId, boolval.Value)
		end)
	until
	success
	
	playerdata[plr.UserId] = nil
end

local function onClosing() -- linked to game:BindToClose()
	for _, plr in pairs(game.Players:GetPlayers()) do -- loops thru all the players
		setData(plr)
	end
end

game.Players.PlayerAdded:Connect(function(plr) -- player joined
	local boolval = Instance.new("BoolValue")
	boolval.Name = "put your own name here"
	boolval.Parent = plr -- you can set it to whatever you want
	
	playerdata[plr.UserId] = boolval
	
	getData(plr)
end)

game.Players.PlayerRemoving:Connect(function(plr) -- player left
	setData(plr)
end)

game:BindToClose(onClosing) -- this fires whenever the server is about to close