|
| 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
|
  |
| 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 |
|
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|