Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to add BodyVelocity to every part in the workspace?

Asked by 10 years ago

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

Log in to vote
1
Answered by
Vathriel 510 Moderation Voter
10 years ago
for i,v in pairs(game.Workspace:GetChildren()) do
if v:IsA("BasePart") then
Instance.new("BodyVelocity",v)
else
end
end
0
Thank you sir Kepler16b 10 — 10y
Ad
Log in to vote
0
Answered by
hiccup111 231 Moderation Voter
10 years ago
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

Answer this question