Best way to fling parts away from a part

hey.
i’m wondering what the best way to fling a part is. i dont wanna use body velocity but if i have to, i can.
basically, if a part spawns, and other parts are touching it, whats the best way to fling them out of the part? ex. like an explosion.

thanks!

1 Like

Use the part’s property called AssemblyLinearVelocity and play the values.

1 Like

yea… but doesn’t assemblylinearvelocity go in only 1 direction? i need it to be flung away from the part, no matter its position relative to the part, as long as it’s touching. plus, collisions on the part are false.

1 Like

also, what should i use instead of snap constraint because its depreciated? i dont wanna have to set parts attachments 1 and 0 manually…

1 Like

Is the .CanTouch on the part is still true? If yes then it still fires the .Touched Event even if the .CanCollide is false.


Maybe you should use WeldConstraints
WeldConstraint | Documentation - Roblox Creator Hub
You only need two parts for it. (Part0 and Part1)

1 Like

cool with assembly linearvelocity but

i dont wanna have to make more than 500 weld constraints.

1 Like

Well you also don’t want 1000 attachments (i think).

And if you could be more specific on what you’re doing.

1 Like


this is a good example.

1 Like

assemblylinearvelocity is a vector3, which means it accepts 3 values for the x, y, and z axis. heres a very simple script for flinging a part away from a part its touching

local velocity = 100 -- how much you want to fling it
local part = script.Parent -- or whatever the parts path is

part.Touched:Connect(function(hit)
	local launchDirection = CFrame.lookAt(hit.Position, part.Position).LookVector
	-- creates a cframe that looks at the part starting from the hit and gets the lookvector. i think theres a simpler way of getting the launch direction this but i forgot

	part.AssemblyLinearVelocity = launchDirection * velocity -- flings it to the launch direction
end)
1 Like

sorry i took so long to reply. thanks for your help!

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