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

Why does this BodyPosition script not work?

Asked by
Nidoxs 190
8 years ago

This UNION OPERTION part should "glide" between 2 parts every 15 seconds however, the union is unanchored and when I play solo it falls when it should be in the air due the Body Position and start gliding towards the target part

What is wrong with this script?

local a = script.Parent
a.BodyGyro.maxTorque = 40000,0,40000
wait(.01)
a.Anchored = false

while true do
local b = Instance.new("BodyPosition", a)
b.maxForce = Vector3.new(5000000,5000000,5000000)
b.position = a.Parent.P2.Position
wait(15)    
b.position = a.Parent.P1.Position
wait(15)
b.Parent = nil
end


0
Try, a.Anchord = true NotSoNorm 777 — 8y
0
Why can't people learn to read the output ;/ Ryzox 220 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

My guess is that on line 2 maxTorque is supposed to be a Vector3 value, but instead of had 3 numbers in a "table-like-fashion". Just put "Vector3.new(" and ")" around the numbers. I think the reason the BodyPosition isn't working is because it isn't even created because the error on line 2 is preventing the rest of the script to work.


Final Product

local a = script.Parent
a.BodyGyro.maxTorque = Vector3.new(40000,0,40000) --Fixed.
wait(.01)
a.Anchored = false

while true do
local b = Instance.new("BodyPosition", a)
b.maxForce = Vector3.new(5000000,5000000,5000000)
b.position = a.Parent.P2.Position
wait(15)    
b.position = a.Parent.P1.Position
wait(15)
b.Parent = nil
end

Hope it helps!

Ad

Answer this question