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

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

	LB.Parent = plr
	p.Parent = LB
	r.Parent = LB
	z.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)
	LevelData:SetAsync(plr.userId, plr.leaderstats.Level.Value)
end)

Please help, thanks.****

6 comments

0

You never told the script to save the data...

0

i am not a god at scripting but defining the parents of LB, p, r and z towards the end of your code was not necessary because their parents was already defined when the variables were created in lines 6, 9, 13, and 17 hope this helps a little and helps you find answers to your code quicker,

0

How do I tell the script to save @MathijsM2006

0

line 28-30 is saving, SetAsync.

0

also what masmixel said, you're setting parent twice. are you testing this live or on studio?

0

Studio, its for a game. im making a simulator a year round one i still need a name and stuff, my only problem is when they join back the leaderstats don't load.