Click-to-move pad is giving me a hard time

Hey gamers. I was trying to make a click-to-move pad like classic roblox for nostalgic and useful purposes.

For some reason this is firing even if the mouse.Target does equal mpoint.Name (my part in workspace).

I have tried to find a solution on here but I haven’t come across one. This should work, and this is my problem.

while true do
	wait()
if click == false	then
	print(mouse.Target)
	print(mpoint.Name)
	
	
		if mouse.Target ~= mpoint.Name then 

				mpoint.Position = Vector3.new(mouse.Hit.p.X, mouse.Hit.p.Y + 0.5 , mouse.Hit.p.Z)
	print(mpoint.Position)
	print("bruhhh this code is so garbage", mouse.Hit)
	end
	
end
end

If I were to change this to happen if it were true, which according to the output is supposed to be happening, the part never fixes itself and stays still even if this is the only time it should be moving.

 if mouse.Target == mpoint.Name then

The reason why I need to tell if it is touching itself or not is because it will take its current position and move on top of it and fly away. This video demonstrates it working and it doing the fly thing.

edit: fixed up a paragraph

This is because you’re comparing mouse.Target, which is an instance, to mPoint.Name, which is a string.

Those aren’t the same data types, so that condition will always evaluate to true; it will run each time it’s ran.

Quick fix; just index the Name property of Target:

if mouse.Target.Name ~= mpoint.Name then
--//blah
end
1 Like

Right. Thank you sir. Exactly what I needed. I should’ve realized it wasn’t comparing to a string.

1 Like