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

Why does this BodyPosition script not work?

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


2 comments

0

Try, a.Anchord = true

0

Why can't people learn to read the output ;/

1 answer

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!

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