Plugin crashes Studio persistently

Hey everybody, I recently started making a plugin for Studio. Recently I added a spinning icon that uses tweens, but since I added that it started crashing Roblox Studio. I would love some help on this because I can’t figure out where the problem is!
This is the code I added that made it start crashing:

local loadingIcon = createImg("27278177", UDim2.new(0, 10, 1, -30), UDim2.new(0, 20, 0, 20))
local info = TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out)
local newInfo = {Rotation = 360}
local newTween = tweenService:Create(loadingIcon, info, newInfo)

local function spinIcon()
	while true do
		if loadingIcon.Visible then
			newTween:Play()
			loadingIcon.Rotation = 0
		else
			wait(0.5)
		end
	end
end
spawn(spinIcon)
createBtn("Global count", UDim2.new(0, 10, 0, 175), function()
	local total = 0
	for i,thing in pairs(game:GetDescendants()) do
		if thing:IsA("BasePart") then
			total += 1
		end
	end
end)

It’s most likely crashing due to the while true loop running and only waits if the loading icon isnt visible, try adding a wait after the loadingIcon.Rotation = 0

1 Like

Thank you! I overlooked that small thing. Thanks for pointing it out again! It works perfectly now.