Whenever people join my game, it lags like crazy. The chat is broken, and people walk in place. From my research, it appears to be coming from a points saver script. However, this script is critical. and I need it. The model is a data saver. The other suspect is a leaderboard creator. At some point when there is a PlayerAdded function, it messes the whole server up. Please help!

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("GemSaveSystem")

game.Players.PlayerAdded:connect(function(plr)
	local folder = Instance.new("Folder", plr)
	folder.Name = "leaderstats"
	local gems = Instance.new("IntValue", folder)
	gems.Name = "Obby Wins"
	
	
	gems.Value = ds1:GetAsync(plr.UserId) or 0
	ds1:SetAsync(plr.UserId, gems.Value)
	
	
	gems.Changed:connect(function()
		ds1:SetAsync(plr.UserId, gems.Value)
	end)
	

	end)

Another suspect:

game.Players.PlayerAdded:connect(function(p)
	local stats = Instance.new("IntValue")
	stats.Name = "leaderstats"
	stats.Parent = p
	
	local money = Instance.new("IntValue")
	money.Name = "Obby Wins" -- Change "Money" to anything you want to name it like "Cash"
	money.Parent = stats
end)

2 comments

0

can you show us the script?

0

Edited the question. @Tyler090130