|
| 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
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
| |
|
| |
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
| |
|
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 |
|
|
|
| 28 May 2015 01:32 PM |
| Forgive me for not udnerstanding. Exactly what IS step and what IS val? |
|
|
| Report Abuse |
|
|
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 |
|
|
| |
|
|
| 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 |
|
|
|
| 28 May 2015 01:40 PM |
| Doesn't work. What am I doing wrong? |
|
|
| Report Abuse |
|
|
|
| 28 May 2015 01:42 PM |
| eLunate, my way worked.. You were just making it complicated.. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 28 May 2015 01:49 PM |
| I ment because im making a mining game and their six suds tall...... |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
| |
|
|
| 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
|
  |
| Joined: 27 May 2012 |
| Total Posts: 2809 |
|
|
| 28 May 2015 04:52 PM |
| no the way you spelt "write is wrong" |
|
|
| Report Abuse |
|
|