spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 24 Jan 2016 01:04 AM |
So i made this simple script to divide a players deaths by kills but it comes out as #INF. Im not really to good with changed events but should i use one to fix the problem?
Kills = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Kills.Value Deaths = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Deaths.Value
while true do script.Parent.Text = "K/D Ratio:" ..Kills/Deaths wait(0) end
But when i do something like this it works
Kills = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Kills.Value
while true do script.Parent.Text = "Kills:" ..Kills end
|
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 24 Jan 2016 01:08 AM |
Neither of your loops have a proper wait.
Try just using wait()
|
|
|
| Report Abuse |
|
|
DrHaximus
|
  |
| Joined: 22 Nov 2011 |
| Total Posts: 8410 |
|
|
| 24 Jan 2016 01:09 AM |
Kills = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Kills.Value Deaths = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Deaths.Value
don't do this.
set Kills/Deaths to the object, not the value. when using the value, do this:
Kills.Value Deaths.Value
you're currently copying the values into variables, they're not references and won't update |
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
| |
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 24 Jan 2016 01:13 AM |
sean your work thnx but now when it divides, there are like 50 numbers on the screen and even coming out of the gui, i there any way to make it so it shows only 3 digits of the ratio and if there is how?
|
|
|
| Report Abuse |
|
|
DrHaximus
|
  |
| Joined: 22 Nov 2011 |
| Total Posts: 8410 |
|
|
| 24 Jan 2016 01:13 AM |
@sean
wait(0) == wait()
but yeah, second loop doesn't block at all |
|
|
| Report Abuse |
|
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 24 Jan 2016 01:15 AM |
well idk wait() worked but wait(0) didnt
|
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 24 Jan 2016 01:18 AM |
It does? I figured it would be a paradox...because you're asking it to wait while the time is none..so it wouldn't wait. Oh well lol
Anyways convert it to a string and use string.sub to get the first few numbers instead of the entire thing. OR you could use math.floor (or math.ceil) but that is only to the nearest integer
http://wiki.roblox.com/index.php?title=Function_dump/String_manipulation#string.sub
|
|
|
| Report Abuse |
|
|
DrHaximus
|
  |
| Joined: 22 Nov 2011 |
| Total Posts: 8410 |
|
|
| 24 Jan 2016 01:21 AM |
@sean
wait defaults the first argument to 0, in the case of the wait time being 0 the "thread" will yield for as little as possible |
|
|
| Report Abuse |
|
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 24 Jan 2016 01:21 AM |
O_O i am not that advanced into scripting yet xd
|
|
|
| Report Abuse |
|
|
seanb117
|
  |
| Joined: 03 Feb 2010 |
| Total Posts: 1020 |
|
|
| 24 Jan 2016 01:22 AM |
Kills = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Kills Deaths = script.Parent.Parent.Parent.Parent.Parent.leaderstats.Deaths
while true do local newtext = ""..Kills.Value/Deaths.Value.."" newtext = string.sub(newtext, 1, 4) script.Parent.Text = newtext wait() end
not tested but should show a number up the the hundredth place. |
|
|
| Report Abuse |
|
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
| |
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 24 Jan 2016 01:39 AM |
@sean it didnt work, it just says label which is the default text so something must be killing the entire function because it doesnt even divide the KILLS/DEATHS.
|
|
|
| Report Abuse |
|
|