Game is lagging hard

Basically, it wasn’t lagging until I changed some of the coding. Instead of normal while loops I use:

task.spawn(function()
		while wait(1) do
			if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, 75562932) == true then
				autosellbutton.Visible = true
				descautosell.Visible = true
			else
				autosellbutton.Visible = false
				descautosell.Visible = false
			end 
		end
	end)
	task.spawn(function() 
		while true do wait(0.1)
			if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, 75562932) == true then
				if autosellbutton.Text == "AUTO SELL: ON" then
					sell:FireServer( "All")
				end
			end
		end
	end)

On client, and the game is insanely lagging. Any ideas?

1 Like

SOLVED: Was because I had a table looped (chances were in like 5m, so it had 5m items in a table) without a task.wait()