Idk what is happening, maybe you can go in debug mode. In debugmode, you can see every single step of your code. This is very usefull. And I should say: „Don‘t use a while wait() do loop“.
EDIT (08/09/2021): Yes, I’ve actually started seeing while task.wait(). Just so it’s clear, the document does cover yielding functions being used as conditions as well. task.wait() is not a better replacement and also falls under discouraged practice as per the below.
Introduction
Earlier today on my usual camp-out by the Scripting Support category, I stumbled across a piece of code that set off my nitpick ringer and reminded me of a document I stumbled across long ago. Today, after being pro…
The DebugMode:
https://developer.roblox.com/en-us/articles/Lua-debugger
It is hard at first, but is very, very usefull with this sorrt of bugs.