I am making a game about smashing stuff. When a thing is smashed, all the parts go anchored = false and move around. After 4 seconds the parts reassemble. The game crashes when the parts reassemble and the output says "maximum event re-entrancy depth exceeded" like 20 times at once. What does that mean?
Background: 5 parts of the total 17 part model have the reassembling script. Here's the script.
function changed() if script.Parent.Value ~= script.Parent.Parent.Position then -- The script.Parent is a vector3value and records the original position of the part. script.Parent.Parent.CFrame = CFrame.new(script.Parent.Value) --The script.Parent.Parent is the part. end end script.Parent.Parent.Changed:connect(changed)
"Maximum event re-entrancy depth exceeded" basically means that events are causing (too much) recursion.
in this particular case, you are waiting for something to change, and when that happens, you change the CFrame. This causes the event to refire, and thus, a very rapid recursion.
Either avoid this altogether, or verify that the CFrame change will not cause the event to change anything else.