Hey DevForums! I was working on a physics game and was wondering the best way on how I can check if a number is negative. I’ve tried making it so if the string of the number value contains “-”, it will do math.abs(Number). But I get errors in the output, leading me to think that the method I was using isn’t a very good idea.
Well here’s the script:
local Distance = Character:WaitForChild("REye").Position.Magnitude - HookPart.Position.Magnitude
if Distance:match("-") then
Distance = math.abs(Distance)
else
return
end
local TweenTime = 0.03 * Distance
The script is a serverscript btw (if that even changes anything). But basically, “HookPart” is a projectile that has been shot. So I used magnitude to calculate the distance between it’s orgin and where it is now. With that, the time it takes to tween something is affected (which is what “TweenTime” is).
So any ideas? Thanks!