of     2   
chevron_rightchevron_rightchevron_right

zaniac10
#189857469Saturday, May 28, 2016 12:38 AM GMT

for _,v in next, boxes do local wear = math.random(1,1000) local num = math.random(1,1000) local b = v if b.Name:sub(1,12) == "RandomNumber" then if wear <= 200 then b.Wear.Value = "Factory New" elseif wear 200 then b.Wear.Value = "Minimal Wear" b.Cash.Value = b.Cash.Value * .8 elseif wear 400 then b.Wear.Value = "Field-Tested" b.Cash.Value = b.Cash.Value * .6 elseif wear 600 then b.Wear.Value = "Well-Worn" b.Cash.Value = b.Cash.Value * .4 elseif wear 800 then b.Wear.Value = "Battle-Scarred" b.Cash.Value = b.Cash.Value * .2 end b.Cash.Value = math.floor(b.Cash.Value+.5) end end end basically cs go stuff where the higher the wear on the item the less it's worth, but it keeps on making all of the cash values 0... anyone know why?
zaniac10
#189867260Saturday, May 28, 2016 3:04 AM GMT

bump
zaniac10
#189868417Saturday, May 28, 2016 3:20 AM GMT

kiko
SkelectroTM
#189869558Saturday, May 28, 2016 3:37 AM GMT

local wear = math.random(1,1000) local num = math.random(1,1000) using two random functions and comparing them will not work because of how lua's pseudo-random function works. It generates a random number from a random seed (usually tick()) that stays the same if you use it twice at the same time. Look up math.randomseed on the roblox wiki. That might explain it better than I have, as I'm just giving you the general idea of it.
cntkillme
#189869652Saturday, May 28, 2016 3:38 AM GMT

Uh, no. He'll more than likely get 2 different numbers.
SkelectroTM
#189870309Saturday, May 28, 2016 3:47 AM GMT

k
zaniac10
#189901107Saturday, May 28, 2016 4:42 PM GMT

so does anyone know the solution?
Kodran
#189901530Saturday, May 28, 2016 4:46 PM GMT

What does b.Cash.Value start as?
zaniac10
#189901714Saturday, May 28, 2016 4:48 PM GMT

0, but code above this(this is key, setting the cash values happens before this set of code) sets it to a certain amount
Kodran
#189901916Saturday, May 28, 2016 4:50 PM GMT

do print(b.Cash.Value) a bunch of times throughout the code to see when/if it changes and what it changes to at each stage.
JarodOfOrbiter
#189902152Saturday, May 28, 2016 4:52 PM GMT

"do print(b.Cash.Value) a bunch of times throughout the code to see when/if it changes and what it changes to at each stage." Or, use the Debugger because it's more fun, has more helpful features and diagnostics, and so forth.
Kodran
#189902265Saturday, May 28, 2016 4:53 PM GMT

Haven't done much roblox scripting in the last while, I didn't even know that was a feature when did they add it?
zaniac10
#189902718Saturday, May 28, 2016 4:58 PM GMT

Entire update function: http://pastebin.com/eb19cxUG
[rfa#hidefromsearch]
#189906841Saturday, May 28, 2016 5:46 PM GMT

[rfa#hidefromsearch]
zaniac10
#189907036Saturday, May 28, 2016 5:48 PM GMT

NumberValue.
zaniac10
#190006039Sunday, May 29, 2016 7:44 PM GMT

Please, you guys... I'm desperate.
zaniac10
#190007470Sunday, May 29, 2016 8:03 PM GMT

Anyone?
zaniac10
#190007949Sunday, May 29, 2016 8:09 PM GMT

Can't the most renowned scripting subforum resolve this?
Kodran
#190008639Sunday, May 29, 2016 8:18 PM GMT

elseif num > 232 then b.BackgroundColor3 = milspec b.Cash.Value = math.random(3,19)/100 end There's a 76.8% chance that this changes cash.Value to somewhere between 0.03 to 0.19 Then you're multiplying it by .2, .4, .6, or .8 making it at most 0.152 which rounds down to 0.
Rockenite
#190009392Sunday, May 29, 2016 8:26 PM GMT

Can't the most renowned scripting subforum resolve this? Can't the only scripting subforum resolve this?* ~~~Da siggy is OP~~~
Kodran
#190009504Sunday, May 29, 2016 8:27 PM GMT

I mean, he's not wrong...
Oslayis
#190010208Sunday, May 29, 2016 8:37 PM GMT

'math.floor(b.Cash.Value+.05)' is your problem. Math.floor rounds it to the nearest integer. In that case, it's 0. Integers don't normally include decimals. So, it'd be best if you did this; math.floor(((b.Cash.Value+.05)*100))/100 Or at least something like that. -DevB
Kodran
#190010881Sunday, May 29, 2016 8:46 PM GMT

@Dev "Integers don't normally include decimals" This sentence gave me cancer. Anyways, he is trying to round to the nearest integer, that's the point of his script. His problem is that he has a logic error I previously pointed out making it likely that the number will always round to 0.
[rfa#hidefromsearch]
#190010895Sunday, May 29, 2016 8:47 PM GMT

[rfa#hidefromsearch]
Oslayis
#190011571Sunday, May 29, 2016 8:56 PM GMT

@Kodran No need to bash on me for trying to help. Just a tip too, in other forums when you want to help someone fix a bug, try to assist them by making their variables local. The game will have less lag, even if it is just the slightest amount.

    of     2   
chevron_rightchevron_rightchevron_right