Okay I know I'm not tripping... This code has nothing wrong with it, yet it still doesn't save my value. PLEASE explain. I beg
Even the output agrees with me that it saved until I rejoin.
local ValueDataStore = game:GetService("DataStoreService"):GetDataStore("SaveValueDataStore")
--Save Value's Value
game.Players.PlayerAdded:Connect(function(player)
local SaveThisValue= player:WaitForChild("PlayerValues",1):FindFirstChild("SaveThisValue")
local valuekey = "Player_"..player.UserId
local GetValuesVal = ValueDataStore:GetAsync(valuekey) or 0
SaveThisValue.Value = GetValuesVal
ValueDataStore:SetAsync(valuekey, SaveThisValue.Value, wait(1))
print("Saved Value!")
end)
game.Players.PlayerRemoving:Connect(function(player)
local SaveThisValue= player:WaitForChild("PlayerValues",1):FindFirstChild("SaveThisValue")
ValueDataStore:SetAsync(player.UserId, SaveThisValue.Value)
end)
What happens is, the output says that this value is saved as true, but when I join the game(the actual game), the value is set back to false... Roblox explain
Everything im testing in is the real game, i dont test in studio

2 comments
Maybe remove 'Wait(1)' on line 10? also try using 'game:BindToClose(function() wait(3) end)' so the server stays up until 3 seconds for everything to save.
What do you mean by join the game? It won't save the value from the game's studio, only the actual in-game value (unless you have studio api enabled, in which the reverse is true)