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: Is this write (Rounding to 6)

Previous Thread :: Next Thread 
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
28 May 2015 01:21 PM
Player.leaderstats.Depth.Value = Player.Character.Torso.Position.Y/6

I want to round it to 6, so that one block count's as 6. Will this work?
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 May 2015 01:24 PM
It's rong
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
28 May 2015 01:25 PM
Can you elaborate??
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 May 2015 01:26 PM
function round(value, step)
return math.floor(value/step+step/2)*step
end
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
28 May 2015 01:27 PM
function RoundToSix(n) --I didn't bother making it number specific
local diff = 6-(n%6)
return diff < 3 and n-diff or n+diff
end


Untested, my logic may have failed miserably, but give it a go :P
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 May 2015 01:28 PM
Bleh.

I meant
function(val, step)
return math.floor(val/step+0.5)*step
end
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
28 May 2015 01:28 PM
So i would say round(6)
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 May 2015 01:31 PM
No you'd say round(value,step)

There's a brain in there and I know it but right now you don't seem to be using it for much more than living
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
28 May 2015 01:32 PM
Forgive me for not udnerstanding. Exactly what IS step and what IS val?
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 May 2015 01:33 PM
Val is the value (Surprise, surprise)
Step is the difference you're rounding it to. In your case, 6.
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
28 May 2015 01:35 PM
OH WOW
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
28 May 2015 01:37 PM
So will this work?

local function Round(Value,Amount)
return math.floor(Value/Amount+0.5)*Amount
end

game:GetService("RunService").Stepped:connect(function()
for _,v in ipairs(game:GetService("Players"):GetPlayers()) do
if v:FindFirstChild("leaderstats") ~= nil and v:FindFirstChild("leaderstats"):FindFirstChild("Depth") ~= nil then
v:FindFirstChild("leaderstats"):FindFirstChild("Depth").Value = v.Character.Torso.Position.Y
Round(v:FindFirstChild("leaderstats"):FindFirstChild("Depth").Value,6)
end
end
end)
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
28 May 2015 01:40 PM
Doesn't work. What am I doing wrong?
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
28 May 2015 01:42 PM
eLunate, my way worked.. You were just making it complicated..
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
28 May 2015 01:46 PM
You said so one block counts as six, not six blocks count as one :D


I script -~ chimmihc
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
28 May 2015 01:49 PM
I ment because im making a mining game and their six suds tall......
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
28 May 2015 02:51 PM
Yeah you didn't really make it too clear because that thing was beautifully ambiguous.

Player.leaderstats.Depth.Value = math.floor(Player.Character.Torso.Position.Y/6)
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
28 May 2015 02:57 PM
Don't copy the quarry
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
28 May 2015 03:04 PM
Im not copying it. It clearly states it is NOT affiliated in any way, and has NO code written by dummiez.
Report Abuse
Luminak is not online. Luminak
Joined: 27 May 2012
Total Posts: 2809
28 May 2015 04:52 PM
no the way you spelt "write is wrong"
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