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: How to round a value?

Previous Thread :: Next Thread 
towerdefence661 is not online. towerdefence661
Joined: 15 Nov 2013
Total Posts: 280
18 Apr 2016 05:21 PM
How do you round a value (number value)?
Report Abuse
Brick_Wizard is not online. Brick_Wizard
Joined: 15 Mar 2016
Total Posts: 2072
18 Apr 2016 05:26 PM
math.ceil, rounds up to the nearest whole number. e.g. math.ceil(3.3) = 4
math.floor, rounds down to the nearest whole number. e.g. math.floor (3.3) = 3
This may come in handy; http://wiki.roblox.com/index.php?title=Function_dump/Mathematical_functions


Report Abuse
towerdefence661 is not online. towerdefence661
Joined: 15 Nov 2013
Total Posts: 280
18 Apr 2016 05:31 PM
while true do
if script.Parent.Parent.TorF.Disabled == true then
script.Parent.Text = math.floor(script.Parent.Parent.Upg1Worker.Value.Value)
script.Parent.Parent.TorF.Disabled = false
wait()
wait()
end
wait()
wait()
end



DOESNT WORK
Report Abuse
Brick_Wizard is not online. Brick_Wizard
Joined: 15 Mar 2016
Total Posts: 2072
18 Apr 2016 05:34 PM
-- Try this
script.Parent.Text = tostring(math.floor(script.Parent.Parent.Upg1Worker.Value.Value))


Report Abuse
towerdefence661 is not online. towerdefence661
Joined: 15 Nov 2013
Total Posts: 280
18 Apr 2016 05:37 PM
nope
Report Abuse
Brick_Wizard is not online. Brick_Wizard
Joined: 15 Mar 2016
Total Posts: 2072
18 Apr 2016 05:38 PM
Add a print("Checker") under the line I gave you to make sure it is actually running.


Report Abuse
towerdefence661 is not online. towerdefence661
Joined: 15 Nov 2013
Total Posts: 280
18 Apr 2016 05:41 PM
well it did print it its just not showing the number on the text.
the script for the Upg1WOrker is

script.Parent.MouseButton1Click:connect(function()
if game.Workspace.cocl.SurfaceGui.TextButton.Value.Value >= 10 then
script.Parent.Parent.Upg1Worker.Disabled = false
script.Parent.Parent.TextButton.Value.Value = script.Parent.Parent.TextButton.Value.Value - 10
script.Parent.Parent.Upg1Worker.Value.Value = script.Parent.Parent.Upg1Worker.Value.Value + 0.3
script.Parent.Parent.TorF.Disabled = true


end
end)
Report Abuse
towerdefence661 is not online. towerdefence661
Joined: 15 Nov 2013
Total Posts: 280
18 Apr 2016 05:42 PM
I ment not the upg1worker the upg1script
Report Abuse
Brick_Wizard is not online. Brick_Wizard
Joined: 15 Mar 2016
Total Posts: 2072
18 Apr 2016 05:44 PM
--Change the print to
print(script.Parent.Text)
-- Make sure this is after
script.Parent.Text = math.floor(script.Parent.Parent.Upg1Worker.Value.Value)


Report Abuse
towerdefence661 is not online. towerdefence661
Joined: 15 Nov 2013
Total Posts: 280
18 Apr 2016 05:46 PM
wait I didnt have to round this whole time.
Report Abuse
Salinas23 is not online. Salinas23
Joined: 28 Dec 2008
Total Posts: 37142
18 Apr 2016 06:28 PM
I mean if you could write down the output or something..

Anyways that wont work if your game is filtering enabled and that is a localscript (which in this case should be cuz its a gui script)


-Salinas con el número 23
Report Abuse
Brick_Wizard is not online. Brick_Wizard
Joined: 15 Mar 2016
Total Posts: 2072
18 Apr 2016 06:28 PM
^ Mhm. I don't think however he is using FilteringEnabled.


Report Abuse
ProtectedMethod is not online. ProtectedMethod
Joined: 01 Apr 2011
Total Posts: 5374
18 Apr 2016 06:31 PM
function round(num)
local decimal = num - math.floor(num);
if(decimal >= .5) then
return math.ceil(num);
else
return math.floor(num);
end
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