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

How can I fix the "attempt to compare boolean with number" problem?


local bodyVelocity = script.Parent.BodyVelocity
local bodyPosition = script.Parent.BodyPosition
while true do
	if 280 < (part.Position - part2.Position).magnitude < 300 then
		bodyVelocity.Velocity = Vector3.new(0,0,0)
		bodyPosition.Position = game.Players.tuanorn.Character.HumanoidRootPart.Position
		bodyPosition.MaxForce = Vector3.new(4000,4000,4000)
	end
	wait()
end

The part doesn't return to my character's HumanoidRootPart. The output said: "attempt to compare boolean and number". How can I fix this?

1 answer

✓ Accepted answer

Try changing line 4 to:

if (part.Position - part2.Position).magnitude > 280 and (part.Position - part2.Position).magnitude < 300 then

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