Studio crashes when I try to :Destroy() a UnionOperation

(I did not stop recording, Roblox Studio crashed)

	local rope = target:FindFirstChildWhichIsA('RopeConstraint')
	rope.WinchTarget = 0
	
	local connection
	connection = rope:GetPropertyChangedSignal('Length'):Connect(function()
		if rope.Length < 0.05 then
			connection:Disconnect()
			target:Destroy()
		end
	end)

I don’t get why this is happening because it doesn’t crash when I try using print() instead of target:Destroy().

A little extra thing with disconnected might help

local rope = target:FindFirstChildWhichIsA('RopeConstraint')

if rope then
    rope.WinchTarget = 0
    
    local connection
    local disconnected = false
    
    connection = rope:GetPropertyChangedSignal('Length'):Connect(function()
        if disconnected then
            return
        end
        
        if rope.Length < 0.05 then
            disconnected = true
            connection:Disconnect()
            target:Destroy()
        end
    end)
end

Just tried that, unfortunately it still crashed.

Maybe add a little ‘wait(1)’ before the target gets destroyed?

1 Like

Oh wow, I can’t believe that actually worked. Thanks a lot!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.