Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make a block break welds of parts around it without bouncing off?

Hello, I am currently making a game where a player can fire blocks from conveyors onto structures that others are standing on. These blocks will take out parts that the structure is made out of. I'm having trouble with it, however. I welded all of the parts of the building together and unanchored them. Then I made and tried the script below:

script.Parent.Touched:Connect(function(hit)
	if hit:IsA("BasePart") or hit:IsA("UnionOperation") then
		hit:BreakJoints()
	end
end)

When I tried it, the welds and parts were only moved immediately after contact with the block, causing the block to bounce back. I want the block to pass clean through, so how do you think I can accomplish this? Any help would be appreciated. Thanks.

2 comments

0

You are waiting for the Block to touch and therefore decelerate. Try using Raycasts (better) or an identical invisible and no-collide block which fires 2 physics-frames earlier and Breaks the Joints (worse). You could also try to save the velocity before impact and continue it after BreakJoints.

0

How could I use a raycast to help?

1 answer

I found a solution, albeit a bit hacky. I made a wait() loop and made it so it updates a value that shows the velocity the block is at. When touched, the block gives the same velocity to the parts it touched. While it's not exactly a clear cut, it definitely knocks them down a lot better than before. Code:

local oldvelocity
while wait() do
	oldvelocity = script.Parent.Velocity
	script.Parent.Touched:Connect(function(hit)
		if hit:IsA("BasePart") or hit:IsA("UnionOperation") then
			hit:BreakJoints()
			hit.Velocity = oldvelocity
		end
	end)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.