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: For some reason I get 7.1...?

Previous Thread :: Next Thread 
jd678 is not online. jd678
Joined: 18 Apr 2008
Total Posts: 11529
05 Feb 2014 11:01 PM
if Gear >=5 and Gear < 7 then
Gear = Gear + 0.1
updateForce()
updateGui()
end


'Gear' will go up to 7.1 NOT 7(What it is supposed to do) THEN stop at 7.1?
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
05 Feb 2014 11:06 PM
Could you tell me what your trying to do here exactly? Give us more of the script? 'Gear' isn't even defined as far as we know
Report Abuse
jd678 is not online. jd678
Joined: 18 Apr 2008
Total Posts: 11529
05 Feb 2014 11:16 PM
the full script is a couple hundred lines.

Gear is defined in the script, but here is an example script:

--LocalScript
Mouse = game.Players.LocalPlayer:GetMouse()
Gear = 5

Mouse.KeyDown:connect(function(key)
if key == "e" then
if Gear >=5 and Gear < 7 then
Gear = Gear + 0.1
updateForce()
updateGui()
else
end
end
end)
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
05 Feb 2014 11:20 PM
I don't see anything wrong with this.. if the Gear's value was 7 then according to the script .1 should be added and you're saying it ends up as 7.1, check if every situation's Gear value that your testing is 7..?
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
05 Feb 2014 11:23 PM
It isn't just his script this is replicated in this script of mine:

x = 5
while (x >= 5 and x < 7) do
x = x + .1
print(x)
end

... Here is my explanation. Lua encounters a weird error when dealing with for example .1, .3, .7 etc. I can't say for sure why. but your best bet would be:

while (x >= 5) do
x = x + .1
if x > 7 then
x = 7
break
end

end
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
05 Feb 2014 11:26 PM
^Only other solution I can think to be viable, I'd go with it.
Report Abuse
jd678 is not online. jd678
Joined: 18 Apr 2008
Total Posts: 11529
06 Feb 2014 12:25 AM
Alright, I figured that'd be my Plan B if nothing could be fixed. The explanation was nice though, thanks!
Report Abuse
iYoshiFox is not online. iYoshiFox
Joined: 14 Apr 2012
Total Posts: 1058
06 Feb 2014 01:05 AM
If it goes up 0.1 more than it should.. Why not end it at 6.9, then have another if statement to see if it is 7?
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
06 Feb 2014 01:13 AM
I'm guessing this is a floating point error...
6.99999999999999999999999999999999999999999999 < 7
+0.1 --not quite .1, but a bit more
->
7.1
Therefore...
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
06 Feb 2014 01:14 AM
Therefore a different solution is

if Gear/10 >= 5 and Gear/10 < 7 then
Gear = Gear + 1
._.
Report Abuse
252Taylor is not online. 252Taylor
Joined: 02 Apr 2012
Total Posts: 1316
06 Feb 2014 01:39 AM
jd1!!
Report Abuse
jd678 is not online. jd678
Joined: 18 Apr 2008
Total Posts: 11529
06 Feb 2014 02:42 AM
ella what r u doing here x3
Report Abuse
252Taylor is not online. 252Taylor
Joined: 02 Apr 2012
Total Posts: 1316
06 Feb 2014 04:01 AM
idk i just saw ur name here and clicked
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