How do I create a magnet?

Greetings,
I am trying to make a magnet (tool) which can attract any object with the metallic material. Is this possible? If not, is there a alternative to this?
If yes, please provide as much reference as possible

Note : Poles do not matter aka attraction between other magnets, I am just looking for a Metal-To-Magnet pull

2 Likes

Now this is something I haven’t thought of.
You could possibly use Region3 and apply some sort of body mover to whatever is inside the Region3, aside from the magnet of course.

1 Like

Most of my experiments are not giving favourable results, I think roblox should implement the material - characteristics to every option

not sure if i understand you correctly, but try this i just made it.
magnet.rbxl (34.9 KB)
(click to turn on the magnet)

2 Likes

You did try RocketPropulsion, right?

LineForce is pretty much made for this. The force of magnetic attraction is governed by the inverse square law, meaning the force is inversely proportional to the square of the distance between the attractors. Or in other words as the distance doubles, the force gets 4 times smaller. LineForce has a built-in property called InverseSquareLaw that makes it behave exactly like this.

Here’s an example setup

And here’s a place file where you can see the effects.

FrikkenMagnetsHowDoTheyWork.rbxl (26.4 KB)

Try testing, then drag one magnet close-ish to the other, and see them attract.

Make sure you set the MaxForce, otherwise the inverse square law will explode the force when the magnets get really close.

4 Likes

This is the tool I was looking for and now I can understand the script, thanks for rblx file :smiley:

I would like to thank @ThanksRoBama for making me aware of LineForce which is much smoother to use and gives in a simpler way of putting in what @TFlanigan showed.
I would like to know what role ApplyAtCenterOfMass and ReactionForce play as I ain’t too thorough with this, interesting properties which I can start using!

1 Like

The wiki is your friend

When disabled only one part will have the force applied (parent of LineForce.Attachment0). When enabled, the other part will also have the same force applied, but in the opposite direction.

When disabled, the force is applied from the point(s) where the attachment(s) are located, which might be different from the center of mass of the assembly. When enabled, the positions of the attachments are ignored so the force is guaranteed to be applied at the center of mass.

If you want more details about what all of that means, read up on torque. E.g. Torque (Moment) (grc.nasa.gov)

1 Like

i wish i knew this exists before!

1 Like

also put this on the end of your script, i forgot about it

tool.Unequipped:Connect(function()
	on.Value = false
end)
1 Like