DataStore Problem

Hello, I’m making a DataStore System that has to save the Datas of a NumberValue inside the playerGui, so when I join all is good, but when I leave, the game says to me: Could not save datas my script on Player Leave is this:

playerData:SetAsync(playerUserId,player:FindFirstChild(“PlayerGui”):FindFirstChild(“CarDataSrores”):WaitForChild(“Nitro”).Value)

PS: I’m new on the DataStore World

1 Like

Unfortunately, saving the PlayerGui is not possible. But you can try to keep the value of Nitro inside the player.

game.Players.PlayerAdded:Connect(function(player)
    local nitro = Instance.new("IntValue")
    nitro.Name = "Nitro"
    nitro.Value = 0
    nitro.Parent = player
end)

And then just save the Nitro value.

While the PlayerGui’s contents do replicate to the server if “Nitro’s” value is being set on the client (via a local script) its value will not be reflected to the server (from the server’s perspective its value will remain unchanged).