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

How to make detect when part has reached Destination?

I realized that a Part in Roblox can not always be equivalent to it's Destination Part. So I was wondering if there was a way to Identify it part was near Destination Part or Detect has nearly stop moving because when I run the script below the Part does appear to stop moving to the naked eye but is always changing it's position slightly by very tiny digits. So can anyone help me with this problem I've encountered. Soldiers = Part Part2 = Destination, so you guys can know what I'm talking about.

while true do  
	wait()
	if Soldiers.Position.X ~= Part2.Position.X then 
		if Soldiers.Position.X > Part2.Position.X then 
			Soldiers.Position = Soldiers.Position - Vector3.new(0.02,0,0)
		end
		if Soldiers.Position.X < Part2.Position.X then 
			Soldiers.Position = Soldiers.Position + Vector3.new(0.02,0,0)
		end
	end
	if Soldiers.Position.Z ~= Part2.Position.Z then
		if Soldiers.Position.Z > Part2.Position.Z then 
			Soldiers.Position = Soldiers.Position - Vector3.new(0,0,0.02)
		end
		if Soldiers.Position.Z < Part2.Position.Z then 
			Soldiers.Position = Soldiers.Position + Vector3.new(0,0,0.02)
		end 
	end
	if Soldiers.Position.X == Part2.Position.X and Soldiers.Position.Z == Part2.Position.Z then -- this part of the script is almost never fired unless on the rare event that it actually meets it's destionation.
		print("oof") 
		break
	end
end

1 answer

you need to program several internal code that will detect several things at the same time,like for example setting the time and date of arriving at system D which is your internal script system!

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