[UNSOLVED] LineForce acting weird

Basically, I am attempting to make planetary gravity, but for some reason, when the game runs though my code:

local planet = script.Parent.MainPlanet
local base = planet.Base
local moon = script.Parent.Moon

local attachment0 = Instance.new("Attachment", moon)
local attachment1 = Instance.new("Attachment", base)

local LineForce = Instance.new("LineForce", moon)

attachment0.Name = "Attachment0"
attachment1.Name = "Attachment1"

attachment0.Position = moon.Position
attachment1.Position = base.Position

LineForce.ReactionForceEnabled = true
LineForce.Attachment0 = attachment0
LineForce.Attachment1 = attachment1
LineForce.Magnitude = 10

The attachment that belongs in the planet is somewhere weird, and the one that belongs in the moon is behind the moon. Why is this?

Attachments “Position” property isn’t absolute. It’s relative. I hope this solves your issue but let me know if you need me to elaborate.

Well what is an alternative to the Position property?

I believe “WorldPosition” is a writeable property of Attachments, I could be wrong though.

Okay I’ll try that, and see if it works. I believe I have an idea for the problem with the moon.

The problem with both of them is simply that you’re setting their Relative position (to the Attachment’s Parent) to their Parents “World” Position

1 Like

When you create an Attachment its Position is 0,0,0 relative to the item, not world space.
Don’t mess with it if you want it centered on the moon or the base.