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

[SIMPLE] Value Change on Button Click?


script.parent.ClickDetector.MouseClick:connect(function(player)
	local thevault = game.Workspace.Vault
	thevault.Value = thevault.Value - 500
end)

This is something really simple im just confused.

Im trying to get the value inside of an object to change when a user clicks on the actual item itself.

Any suggestions?

3 comments

0

Hi! First of all, are you getting any errors in output? Next, is thevault a number value? Finally, is this a local or server script, because if it is local, this value you are changing will not change for anybody else.

0

Hey thanks for the response, the output is this: 17:25:26.976 - Workspace.Block.MoneyClick:4: attempt to perform arithmetic (sub) on Instance and number 17:25:26.977 - Stack Begin 17:25:26.977 - Script 'Workspace.Block.MoneyClick', Line 4 17:25:26.978 - Stack End, and thevault is a parent of a NumberValue, and the script is a normal server script, thanks.

0

I've just posted an answer, hope it helps! :)

1 answer

✓ Accepted answer

Alright, so as you mentioned in your comment, you're getting an error that you are trying to subtract a number from an instance(vault). Instead of this, try changing thevault.Value to thevault.NumberValue.Value, as the actual value is a property of the NumberValue instance.

If this helped, remember to accept it as the answer so that others are not confused. If you have any questions at all, please comment. :D

2 comments

0

Hey thanks for that! I needed to use thevault.Value.Value however your response made sense in rooting the issue (it being trying to perform arithmetic on objects), thanks!

0

No problem! Glad I could help.

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