Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer
script.Parent.MouseButton1Click:connect(onClicked)

Must be:

script.Parent.MouseButton1Down:connect(onClicked)

2 comments

0

So, I changed the Script, I get the output saying "Clicked", but the variable doesn't change.

0

Remove .Value from the tags, and add them to the equations.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.