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: How you add to a NumberValue?

Previous Thread :: Next Thread 
YaYaBinks3 is not online. YaYaBinks3
Joined: 05 Jun 2009
Total Posts: 2631
11 Aug 2011 01:16 PM
Hi. Here I am trying to add one to a NumberValue.

function onTouched(hit)

if hit.Name == "Cheese" then --Basicly the name is cheese.

game.Workspace.CheeseValue.howmuch.Value = +1 --So I add to the value.
hit:Remove() --Remove the cheese

end
end

script.Parent.Touched:connect(onTouched)

Please, if this works, tell me and if it doesn't please fix my script. I want the value to get added to.
Report Abuse
Fl0x is not online. Fl0x
Joined: 06 Aug 2010
Total Posts: 5169
11 Aug 2011 01:17 PM
game.Workspace.CheeseValue.howmuch.Value = game.Workspace.CheeseValue.howmuch.Value+1
Report Abuse
YaYaBinks3 is not online. YaYaBinks3
Joined: 05 Jun 2009
Total Posts: 2631
11 Aug 2011 01:20 PM
Thank you!
Report Abuse
Starryguy is not online. Starryguy
Joined: 07 Dec 2009
Total Posts: 95
11 Aug 2011 01:21 PM
@Fl0x You can't do that. I tried and it failed

local chease = game.Workspace.CheeseValue.howmuch.Value
chease=chease+1
game.Workspace.CheeseValue.howmuch.Value = chease
Report Abuse
Fl0x is not online. Fl0x
Joined: 06 Aug 2010
Total Posts: 5169
11 Aug 2011 01:23 PM
Since you tag the Value's actual value.
Try;

local chease = game.Workspace.CheeseValue.howmuch
chease.Value=chease.Value+1
print(chease)
Report Abuse
grimm343 is not online. grimm343
Joined: 18 Sep 2008
Total Posts: 2796
11 Aug 2011 01:24 PM
local chez = game.Workspace.CheeseValue.howmuch

function onTouched(hit)

if hit.Name == "Cheese" then

chez.Value = chez.Value + 1
hit:Remove()
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
Starryguy is not online. Starryguy
Joined: 07 Dec 2009
Total Posts: 95
11 Aug 2011 01:25 PM
That will error. You can not do maths on a number value. You can only do it if you INPORT the value
Report Abuse
Fl0x is not online. Fl0x
Joined: 06 Aug 2010
Total Posts: 5169
11 Aug 2011 01:29 PM
i=Instance.new("NumberValue") i.Value=5 i.Value=i.Value+1 print(i.Value)
Simple command bar script.
It will result in 6.
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