It’s caused by too many .Parent statements. Remove one
Also consider setting variables such as Player and Character at the start of your script to make them more easily understood. if you added the following to the start of the script:
local Tool = script.Parent
local character = Tool.Parent
Your script can then be simplified. For example:
-- Easier to read what it relates to
Tool.Equipped:Connect(function()
Well yea, you get the infinite yield because there’s no such instance, ‘Character’. When a tool is unequipped, it gets parented to the backpack. I do recommended the above method, but if you still want to fetch the character in the scope you could do:
local player = tool.Parent:FindFirstAncestorOfClass('Player')
local char = player.Character or player.CharacterAdded:Wait()
I got this script from YouTube and didn’t think well.
Now I understand why the behavior became unstable.
Also thank you for showing me another way to fetch the character!