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

How to add BodyVelocity to every part in the workspace?

So far I got this

b = Instance.new("BodyVelocity")
b.Parent = game.Workspace:IsA("Part")

But it does not work and I am confused as to how to add it to every single part in the workspace

2 answers

✓ Accepted answer
for i,v in pairs(game.Workspace:GetChildren()) do
if v:IsA("BasePart") then
Instance.new("BodyVelocity",v)
else
end
end

1 comment

0

Thank you sir

for _,v in pairs(Workspace:GetChildren()) do -- GetChildren returns a list of objects

	if v:IsA("BasePart") then -- aslong as it's a building part
		
		bv = Instance.new("BodyVelocity",v)

	end

end

If you're using this as a sort of anti-gravity, you may be better with 'BodyForce', and setting force.Y to the part's mass * 187:

	bf = Instance.new("BodyForce",v) -- for line 5 onward
	bf.force = Vector3.new(0,v:GetMass()*187,0) -- Mass of (v) * 187

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