Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

On the topic of changing a variable with a Gui Button?

Asked by 10 years ago

So, I'm working on a GUI button, I want the button to Increase a numberValue Variable by 100, I wrote the following code in a local script:

01maxhp = script.Parent.Parent.Parent.Stats.HPTEXT.maxhp.Value
02maxmp = script.Parent.Parent.Parent.Stats.MPTEXT.maxmp.Value
03 
04function onClicked()
05    maxhp = maxhp + 100
06    maxmp = maxmp + 100
07    print 'Clicked!'
08end
09 
10script.Parent.MouseButton1Click:connect(onClicked)

The problem is, the variable doesn't increase, any help?

EDIT: On a side note, I don't even get the feedback in the output tad stating "Clicked!" EDIT 2: FIXED! Thanks for the help!

2 answers

Log in to vote
1
Answered by 10 years ago
1script.Parent.MouseButton1Click:connect(onClicked)

Must be:

1script.Parent.MouseButton1Down:connect(onClicked)
0
So, I changed the Script, I get the output saying "Clicked", but the variable doesn't change. notRezznov 35 — 10y
0
Remove .Value from the tags, and add them to the equations. Drak0Master 172 — 10y
Ad
Log in to vote
1
Answered by
Azenix 1
10 years ago

Also don't do maxhp = script.Parent.Parent.Parent.Stats.HPTEXT.maxhp.Value maxmp = script.Parent.Parent.Parent.Stats.MPTEXT.maxmp.Value remove the value and then

function onClicked() maxhp.Value = maxhp + 100 maxmp.Value = maxmp + 100 print 'Clicked!' end I have noticed that in many of my scripts

Answer this question