Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

my datastore script dont save any data???

local DataStoreService = game:GetService("DataStoreService")
local MyDataStore = DataStoreService:GetDataStore("HaveBreathing")

game.Players.PlayerAdded:Connect(function(player)
	local havebre = Instance.new("Folder")
	havebre.Name = "havebre"
	havebre.Parent = player
	
	local HaveBreathing = Instance.new("IntValue")
	HaveBreathing.Name = "HaveBreathing"
	HaveBreathing.Parent = havebre
end)

game.Players.PlayerRemoving:Connect(function(player)
	MyDataStore:SetAsync(player.UserId, player.havebre.HaveBreathing.Value)
end)

dont save why

2 answers

It IS Saving it, you are just not assigning the value of the "IntValue".

HaveBreathing.Value = MyDataStore:GetAsync(player.UserId)

This should work also, you can put whatever you need inside the code

local sampleDataStore = game:GetService("DataStoreService"):GetDataStore("MyDataStore")
 
game.Players.PlayerRemoving:Connect(function(player)
	local playerKey = "Player_" .. player.UserId
 
	local success, val = pcall(function()
		return sampleDataStore:RemoveAsync(playerKey)
	end)
 
	if success then
		print(val)
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.