How do you use AssemblyLinearVelocity?

  1. What do you want to achieve? Keep it simple and clear!

There is a folder called “Unanchored” which is a direct child of Workspace. It has a bunch of parts in it. All the children of this folder are Unanchored and CanCollide true. I want to simply fling all the descendants of the folder in the x axis (toward the negative direction)

  1. What is the issue? Include screenshots / videos if possible!

The script doesn’t work.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I searched the internet for how to use AssemblyLinearVelocity but don’t understand anything.

Edit: I changed the code to use ApplyImpulse instead, but it still doesn’t do anything.

local function TrainDebris()
	for i, debris in pairs(game.Workspace.Unanchored:GetChildren()) do
		debris:ApplyImpulse(Vector3.new(-30,0,0))
	end
end

TrainDebris()
4 Likes

When setting a property’s value, you should access the property then put an equals sign then the value.

debris.AssemblyLinearVelocity = Vector3.new(-30,0,0)
1 Like

For assemblylinearvelocity the parts need to remain anchored.

I want them to get flung, so I don’t see how them being anchored would do anything

2 Likes

I should’ve specified better, but I want them to be flung and fall on the ground, as if they were unanchored parts that were tossed into the sky. But in this case, they’re being tossed to the side.

Look into this instead it might be better application for what you are trying to do:

https://developer.roblox.com/en-us/api-reference/function/BasePart/ApplyImpulse

local function TrainDebris()

for i, debris in pairs(game.Workspace.Unanchored:GetDescendants()) do

debris:ApplyImpulse(Vector3.new(-30,0,0))

end

end

TrainDebris()

And if this script works, how far would the parts land from their original position? Would it be 30 studs or would it be something different?

The reason they’re being tossed to the side is because you did not set the Y value. So try adding adding 30 to the Y value.

With a physics engine there isn’t a clear answer how far they should be moved, just that 30 units of force has been applied. Keep in mind force = mass * acceleration, so you may need a lot more force to have them flying across the place depending on the mass.

Use ``` to wrap your code blocks, they will be easier to read.

This:
```
local function TrainDebris()
print(“my code”)
end
```

turns into:

local function TrainDebris()
    print("my code")
end
1 Like

I know, but I couldn’t find that on mobile

I want them to get tossed to the side

I tried that but it still doesn’t work, I edited the topic with the new code

How does your script fail? if there are errors please post them, otherwise go into detail about what “doesn’t work” means.

Did you try setting it to a much larger number? The first paragraph in my reply mentions how the distance traveled will be based on mass, a lighter object goes farther.

What is the mass of each part you are trying to toss? If they are heavy you will need to adjust your vector force accordingly since it relies on the mass of the part… maybe try a much higher number to test it out :

It’s a SmoothPlastic part if that does anything with mass

You might have to call it in local scripts if the parts are owned by the client side or set ownership to nil for the part. I realized I might be a little late

This was years ago but iirc i just used apply impulse lols