generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Question about rounding a part's position

Previous Thread :: Next Thread 
ZBoyer1000 is not online. ZBoyer1000
Joined: 10 Feb 2013
Total Posts: 271
12 Aug 2015 04:35 PM
Is there any way to round a part's position to the nearest number?

Report Abuse
IanSplodge is not online. IanSplodge
Joined: 13 Aug 2012
Total Posts: 2686
12 Aug 2015 04:38 PM
I used to have a code that did this, but I had it on the Family PC that we had to reset and I forgot how I did it.
But if it helps, it should be possible.
Report Abuse
IanSplodge is not online. IanSplodge
Joined: 13 Aug 2012
Total Posts: 2686
12 Aug 2015 04:39 PM
function roundToNearest4(num)
local remainder = num % 1
local numfloored = num - remainder
if remainder / 1 >= 0.5 then
return numfloored + 1
else
return numfloored
end
end


FOUND IT!

Should work, sorry if it doesn't. It rounds a number to the neared whole number.
Report Abuse
Sasayaki is not online. Sasayaki
Joined: 29 Jun 2007
Total Posts: 33868
12 Aug 2015 04:53 PM
"function roundToNearest4(num)
local remainder = num % 1
local numfloored = num - remainder
if remainder / 1 >= 0.5 then
return numfloored + 1
else
return numfloored
end
end"

Alternatively

function roundToNearest4(num)
return math.floor(num+.5)
end
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image