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 » Scripting Helpers
Home Search
 

Re: Script to round the position of objects not functioning

Previous Thread :: Next Thread 
compy111 is not online. compy111
Joined: 02 Apr 2009
Total Posts: 583
23 Jun 2013 10:49 AM
I always thought round is used to round a value like 3.9995 into 4 but now it says round is a nil value. What's wrong?

parts = game.Workspace:GetChildren()
for i=1, #parts do
if parts[i].ClassName == "Part" then
print("Part being relocated")
newx = (round(parts[i].Position.X/4))*4
newy = (round(parts[i].Position.Y/4))*4
newz = (round(parts[i].Position.Z/4))*4
parts[i].Position = Vector3.New(newx, newy, newz)
end
end

(The reason I make this script is because I built a huge church, looks quite cool and the stamper tool somehow messed it up and there are gaps in the walls at some locations)
Report Abuse
Regress is not online. Regress
Joined: 23 Jul 2011
Total Posts: 119
23 Jun 2013 11:00 AM
I don't think theres a round operator in lua, but there are plenty of hackish methods for it.

http://lua-users.org/wiki/SimpleRound
Report Abuse
ZekeZakKaz is not online. ZekeZakKaz
Joined: 31 Mar 2012
Total Posts: 13907
23 Jun 2013 11:17 AM
[ Content Deleted ]
Report Abuse
compy111 is not online. compy111
Joined: 02 Apr 2009
Total Posts: 583
23 Jun 2013 11:20 AM
The only thing you chqnged is *4 into *3 isn't it?
It has to be *4. Just want to get all parts (all parts are 4 by 4 by 4) back on the place they should be at.
Report Abuse
ZekeZakKaz is not online. ZekeZakKaz
Joined: 31 Mar 2012
Total Posts: 13907
23 Jun 2013 11:21 AM
[ Content Deleted ]
Report Abuse
compy111 is not online. compy111
Joined: 02 Apr 2009
Total Posts: 583
23 Jun 2013 11:28 AM
4 can't be a nil value, 4 is 4.
It says round is a nil value. Not 4.
Report Abuse
Drak0Master is not online. Drak0Master
Joined: 10 Aug 2009
Total Posts: 836
23 Jun 2013 11:37 AM
You can make a supervisor code for your desired rounding.

This is just an improvised example.. Haven't needed to do this in a long time...

round = 1 -- 2,-1,0(decimal), 1,2

number = 123.4
wholelength = tostring(tonumber(math.floor(number)))
decimal = tonumber(string.sub(number,#wholelength,(#wholelength+1+round)))
if decimal == 5 or decimal >= 5 then
number = tonumber(wholelength)+1
else
number = tonumber(wholelength)
end

A.K.A. math.floor()
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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