How can I make a magnet using LineForces less glitchy?

I’m currently working on a magnet in a game where you collect objects. This is the script of the magnet itself:

while true do
	wait(1)
	for i,v in pairs(game.Workspace.ObjSpawningScript.SpawnedObjects:GetChildren()) do
		if (Hum.Position - v.Position).Magnitude < 24 then
			local Attach = Instance.new("Attachment")
			local Attach1 = Instance.new("Attachment")
						
			Attach.Parent = Hum
			Attach1.Parent = v
						
			local force = Instance.new("LineForce")
			
			force.Parent = Hum
					
			force.Attachment0 = Attach1
			force.Attachment1 = Attach
						
			force.ReactionForceEnabled = false
			force.MaxForce = 500
		end
	end
end

It does the job, however, very glitchy.

What I mean by glitchy is that the object makes contact with the HumanoidRootPart of the player, and player can climb on the object and replicate a ladder effect.

Is there a way to do this ? I have considered making the object uncollidable, but my game relies on .Touched() events to see when player collects a hat.

Much appreaciation.

2 Likes

If the player is ‘climbing’ your object when a player approaches it, you need to make it so that the player can not physically interact with the object. You can either remove the object when a player hits it or disable the physical collision. A touched event will still work with physical collisions disabled.

The player is climbing the object for a split second, before the object disappears, as the player just touched it.

How can I disable physical collisions ?

You can set the part’s CanCollide property to false or use Collisions | Documentation - Roblox Creator Hub

1 Like