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
 

Division = #INF? Changed event?

Previous Thread :: Next Thread 
spinywind is online. 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 is not online. 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 is not online. 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 is not online. seanb117
Joined: 03 Feb 2010
Total Posts: 1020
24 Jan 2016 01:11 AM
^
That too.
Report Abuse
spinywind is online. 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 is not online. 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 is online. 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 is not online. 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 is not online. 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 is online. 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 is not online. 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 is online. spinywind
Joined: 26 Jan 2012
Total Posts: 3580
24 Jan 2016 01:31 AM
ty so much ^


Report Abuse
spinywind is online. 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
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