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 » Scripting Helpers
Home Search
 

Re: Strange glitch with values?

Previous Thread :: Next Thread 
iiUltimate is not online. iiUltimate
Joined: 29 Mar 2012
Total Posts: 3694
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
iiUltimate is not online. iiUltimate
Joined: 29 Mar 2012
Total Posts: 3694
03 Oct 2014 10:46 PM
b1
Report Abuse
iiUltimate is not online. iiUltimate
Joined: 29 Mar 2012
Total Posts: 3694
03 Oct 2014 10:47 PM
b2
Report Abuse
iiUltimate is not online. iiUltimate
Joined: 29 Mar 2012
Total Posts: 3694
03 Oct 2014 10:52 PM
b3
Report Abuse
iiUltimate is not online. iiUltimate
Joined: 29 Mar 2012
Total Posts: 3694
03 Oct 2014 10:57 PM
b4
Report Abuse
warriorqaz is not online. warriorqaz
Joined: 09 Oct 2009
Total Posts: 726
03 Oct 2014 10:58 PM
So is thatval a number value or some other type of value?
Report Abuse
iiUltimate is not online. iiUltimate
Joined: 29 Mar 2012
Total Posts: 3694
03 Oct 2014 10:58 PM
thatval, as well as thatotherval are both integer values.
Report Abuse
warriorqaz is not online. warriorqaz
Joined: 09 Oct 2009
Total Posts: 726
03 Oct 2014 11:00 PM
Integers are numbers. Go to the value in Workspace and tell me what the className is.
Report Abuse
iiUltimate is not online. iiUltimate
Joined: 29 Mar 2012
Total Posts: 3694
03 Oct 2014 11:01 PM
"IntValue"
Report Abuse
warriorqaz is not online. warriorqaz
Joined: 09 Oct 2009
Total Posts: 726
03 Oct 2014 11:03 PM
Change it to a number value. Int values won't work.
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
03 Oct 2014 11:08 PM
Why would an IntValue not work?
Report Abuse
iiUltimate is not online. iiUltimate
Joined: 29 Mar 2012
Total Posts: 3694
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 is not online. 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
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
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
warriorqaz is not online. warriorqaz
Joined: 09 Oct 2009
Total Posts: 726
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
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
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
iiUltimate is not online. iiUltimate
Joined: 29 Mar 2012
Total Posts: 3694
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
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
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 is not online. 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
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
03 Oct 2014 11:18 PM
Oh my god no you were not im terribly sorry.

Too tired to function.

Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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