sort of a big problem here since it worked, but now the game doesn't wanna load up at all and it takes a long while to open it

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("DeathSaveSystem")
local ds2 = datastore:GetDataStore("BrickSaveSystem")

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local bricks = Instance.new("IntValue")
	bricks.Name = "Bricks"
	bricks.Parent = leaderstats
	
	local deaths = Instance.new("IntValue")
	deaths.Name = "Deaths"
	deaths.Parent = leaderstats
	
	player.CharacterAdded:Connect(function(char)
		local humanoid = char:FindFirstChild("Humanoid")
		humanoid.Died:Connect(function()
			deaths.Value = deaths.Value + 1
		end)
	end)
	
	
	bricks.Value = ds2:GetAsync(player.UserId)
	ds2:SetAsync(player.UserId, bricks.Value)
	
	deaths.Value = ds1:GetAsync(player.UserId)
	ds1:SetAsync(player.UserId, deaths.Value)
	
	game.Players.PlayerRemoving:Connect(function(player)
		ds2:SetAsync(player.UserId, bricks.Value)
		ds1:SetAsync(player.UserId, deaths.Value)
	end)
end)

4 comments

0

dont put playerremoving inside playeradded it hurts my soul

0

so i should just add another end to it?

0

I write this answer yesterday, but after 1 min u have deleted the post.

0

because it didn't work???