PointData = game:GetService("DataStoreService"):GetDataStore("PointData")
RebirthData = game:GetService("DataStoreService"):GetDataStore("RebirthData")

game.Players.PlayerAdded:Connect(function(plr)
	local LB = Instance.new("IntValue")
	LB.Name = "leaderstats"
	
	local p = Instance.new("IntValue")
	p.Name = "Points"
	p.Value = PointData:GetAsync(plr.userId) or 0
	
	local r = Instance.new("IntValue")
	r.Name = "Rebirths"
	r.Value = RebirthData:GetAsync(plr.userId) or 0

	LB.Parent = plr
	p.Parent = LB
	r.Parent = LB
end)

game.Players.PlayerRemoving:Connect(function(plr)
	PointData:SetAsync(plr.userId, plr.leaderstats.Points.Value)
	RebirthData:SetAsync(plr.userId, plr.leaderstats.Rebirths.Value)
end)

4 comments

0

ok why make the title all caps stop screaming at me plz

0

userid should be spelled like "UserId" and you should use the pcall function when calling datastores https://developer.roblox.com/en-us/api-reference/lua-docs/Lua-Globals

0

Marked as non-descriptive as the OP doesn't specify what part doesn't work.

0

I think that giving it medicine will make it work well.