I'm trying to make a magnetic part, that attracts certain things to it. I'm using BodyVelocity, but i'm not really sure how to go about attracting other parts to the magnet.
local l = prt:clone() ---this is the magnet, just imagine its in the workspace and all that stuff
for i, v in pairs(game.Workspace:GetChildren())do
if v:findFirstChild("Humanoid")then
if v:findFirstChild("Humanoid") ~= player.Character:findFirstChild("Humanoid")then
print(v)
if(l.Position-v.UpperTorso.Position).magnitude <=50 then
local bv = Instance.new("BodyVelocity", v)
bv.MaxForce = Vector3.new(1e8,1e8,1e8)
bv.Velocity = l.lookVector * v:findFirstChild("RicoStacks").Value -------RicoStack is a NumberValue that i want the velocity to go by
end
end
end
end

3 comments
nothing is happening when i used ur script
also what is bodyposition
BodyPosition moves a part toward a set position. Just set the BodyPosition's position equal to the magnet's position.