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:

maxhp = script.Parent.Parent.Parent.Stats.HPTEXT.maxhp.Value
maxmp = script.Parent.Parent.Parent.Stats.MPTEXT.maxmp.Value

function onClicked()
    maxhp = maxhp + 100
    maxmp = maxmp + 100
    print 'Clicked!'
end

script.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
script.Parent.MouseButton1Click:connect(onClicked)

Must be:

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