I'm trying to subtract 2 vectors and get the percentage of how close they are, this is what I got so far ( don't really like it because even if one of the bricks is way off it would give something like 89% instead of somewhere around 10%)
100 - ((brick1.Position / brick2.Position).magnitude * 100)
EDIT: Apparently this isn't what you wanted, but I'll keep it for future reference :P
First off, I believe you get magnitudes using subtraction, not division, so:
local mag = (pos1-pos2).Magnitude
Next, to use percentages, you need to have a value that state's what 100% would be, so:
local distanceToTravel = (pos1-pos2).Magnitude
Then, to calculate the percentage, you get the maximum percentage (100%), divide it by the "100% value", then times it by the current value:
-- I also added in a few other things :) local distanceToTravel = (start-destination).Magnitude local travelledDistance = false while travelledDistance == false do -- looping to update local percentage = 100/distanceToTravel*((curPos-destination).Magnitude) if percentage >= 100 then -- checks to see if percentage is 100 travelledDistance = true -- disables loop end end
Hope I helped! If you have any questions, please ask!
~TDP