fix() Runs exactly twenty-one times then quits. Any ideas?
(I already did a print debug, which determined everything up until then works)
repeat wait() until Workspace:FindFirstChild(Game.Players.LocalPlayer.Name) local p=Instance.new("Part") p.Transparency=1 p.Size=Vector3.new(2, 2, 2) p.CanCollide=false print(3) p.Parent=Game.Players.LocalPlayer.Character local mouse=Game.Players.LocalPlayer:GetMouse() local b = Instance.new('BodyGyro') b.maxTorque = Vector3.new(math.huge, math.huge, math.huge) print(7) b.cframe = mouse.hit b.Parent = p local active=false i=1 function fix() print(i) i=i+1 if active==false then active=true p.CFrame=Game.Players.LocalPlayer.Character.Head.CFrame p.CFrame=CFrame.Angles(0, math.rad(p.Rotation.Y), 0) b.cframe=mouse.hit active=false end end p.Changed:connect(fix) Game.Players.LocalPlayer.Character.Head.Changed:connect(fix) mouse.Changed:connect(fix)
I modified your script a little to display the name and property each time the Changed event occurs so you know exactly what is changing.
repeat wait() until Workspace:FindFirstChild(Game.Players.LocalPlayer.Name) local p=Instance.new("Part") p.Transparency=1 p.Size=Vector3.new(2, 2, 2) p.CanCollide=false print(3) p.Parent=Game.Players.LocalPlayer.Character local mouse=Game.Players.LocalPlayer:GetMouse() local b = Instance.new('BodyGyro') b.maxTorque = Vector3.new(math.huge, math.huge, math.huge) print(7) b.cframe = mouse.hit b.Parent = p local active=false i=1 function fix(part, property) print(i, part, property) i=i+1 if active==false then active=true p.CFrame=Game.Players.LocalPlayer.Character.Head.CFrame p.CFrame=CFrame.Angles(0, math.rad(p.Rotation.Y), 0) b.cframe=mouse.hit active=false end end p.Changed:connect(function(prop) fix("p", prop) end) Game.Players.LocalPlayer.Character.Head.Changed:connect(function(prop) fix("Head", prop) end) mouse.Changed:connect(function(prop) fix("mouse", prop) end)
Following is the output:
3
7
1 Head BrickColor
2 p CFrame
3 p Position
4 p Rotation
5 p CFrame
6 p Position
7 p Rotation
8 Head Color
9 p CFrame
10 p Position
11 p Rotation
12 p CFrame
13 p Position
14 p Rotation
15 p Parent
16 p CFrame
17 p Position
18 p Rotation
19 p CFrame
20 p Position
21 p Rotation
From this you can see that the CFrame and Position of the part continue to change as the part falls out of the world. Once the part is destroyed by falling too far, it stops receiving Changed event calls and so it stops writing to the console.
It seems you are not expecting this part to fall to its doom but that is what is happening.
Your debounce doesn't really work properly as there is no waiting before "deactivating", which basically renders it useless.
That's what I think causes the problem. Give it a try:
repeat wait() until Game.Players.LocalPlayer.Character local p = Instance.new("Part", game.Players.LocalPlayer.Character) p.Transparency = 1 p.Size = Vector3.new(2, 2, 2) p.CanCollide = false print(3) local mouse = Game.Players.LocalPlayer:GetMouse() local b = Instance.new('BodyGyro', p) b.maxTorque = Vector3.new(math.huge, math.huge, math.huge) print(7) b.cframe = mouse.hit local active = false local i = 1 function fix() print(i) if active == false then i = i + 1 active = true p.CFrame = Game.Players.LocalPlayer.Character.Head.CFrame p.CFrame = CFrame.Angles(0, math.rad(p.Rotation.Y), 0) b.cframe = mouse.hit wait(0.1) active = false end end p.Changed:connect(fix) Game.Players.LocalPlayer.Character.Head.Changed:connect(fix) mouse.Changed:connect(fix)