|
| 03 Oct 2014 10:43 PM |
I've been trying something with values, however, I've noticed some strange glitch. I'll demonstrate. Since it's a core script with over 400 lines, I'll just make an example of what went wrong. (Becuase I don't need the entire script shown to fix)
thatval=script.Parent:WaitForChild('Level') thatotherval=script.Parent:WaitForChild('XP') XPBar=script.Parent:WaitForChild("XPBar")
function blahblah() XPBar.Size=UDim2.new((thatval.Value*25)/thatotherval.Value,0,1,0) end
while wait(0.1) do blahblah() end
-- ERROR: Line 7 // Attempt to index global thatval (a number value) [ It's clearly not a number value, considering it's an integer. ]
-- Can you guys help? I never understood why this happens. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
|
| 03 Oct 2014 10:58 PM |
| So is thatval a number value or some other type of value? |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 10:58 PM |
| thatval, as well as thatotherval are both integer values. |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 11:00 PM |
| Integers are numbers. Go to the value in Workspace and tell me what the className is. |
|
|
| Report Abuse |
|
|
| |
|
|
| 03 Oct 2014 11:03 PM |
| Change it to a number value. Int values won't work. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 03 Oct 2014 11:08 PM |
| Why would an IntValue not work? |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 11:09 PM |
| I don't understand this problem, still, it has an error if I say ".Value" at the end, and another if I don't. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 03 Oct 2014 11:11 PM |
| Can we see the 2 lines before line that you did not show us? |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 11:12 PM |
| Might not help since the error is not the "nil value" -one but give this idea a go: Try using "wait(1)" after the waitforchilds |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 11:13 PM |
| I said intValues might not work because he could be using decimals. It would be safer to use a number value. |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 11:15 PM |
Safer? Safer how?
If he doesn't need decimals then he is fine using integers. I'm not entirely sure how Lua handles numbers, but AFAIK integers should use way less memory too (not that it makes a difference 10 times per second on really simple calculus) |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 11:15 PM |
| @qazwarrior, generally I never encounter having to use decimals, since my project is a very simple turn based RPG. And also I'm adding saving soon, and I don't believe numbervalues are stored as easily. |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 11:17 PM |
AHA! Found it! You were missing a parenthesis.
thatval=script.Parent:WaitForChild('Level') thatotherval=script.Parent:WaitForChild('XP') XPBar=script.Parent:WaitForChild("XPBar")
function blahblah() XPBar.Size=UDim2.new( ( (thatval.Value * 25) / thatotherval.Value, 0, 1, 0 ) end
while wait(0.1) do blahblah() end |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 03 Oct 2014 11:17 PM |
If you put a decimal number in an IntValue it just rounds the number
Its not safer to use a normal NumberValue |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 11:18 PM |
Oh my god no you were not im terribly sorry.
Too tired to function.
|
|
|
| Report Abuse |
|
|