Changed connection causing performance issues

Upon microprofiling my game to see what’s causing an abnormal average ping, I wonder that the connection Changed was cause, why?


Could it be that or something else? GetNumAwakeParts() returns 0.

Character:WaitForChild("HumanoidRootPart"):GetPropertyChangedSignal("Position"):Connect(function()
	if (Character.PrimaryPart.Position - _G.CattoShop.Position).Magnitude >= 10 then
		if Character:FindFirstChild("CattoShopFF") then
			Character:FindFirstChild("CattoShopFF"):Destroy()
		end
	end
	if (Character.PrimaryPart.Position - _G.Dealer.Position).Magnitude >= 10 then
		if Character:FindFirstChild("DarkShopFF") then
			Character:FindFirstChild("DarkShopFF"):Destroy()
		end
	end
end)
2 Likes

I mean this is a server script, and every time a player in the game moves even half a stud, the connection is fired. So you can imagine, with even just 10 players the server script will cause a lot of lag due to being fired multiple times per second per player.