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

[SIMPLE] Value Change on Button Click?

Asked by 3 years ago
Edited 3 years ago

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?

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. Warphi 51 — 3y
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. Dullbuilderman26 11 — 3y
0
I've just posted an answer, hope it helps! :) Warphi 51 — 3y

1 answer

Log in to vote
0
Answered by
Warphi 51
3 years ago

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

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! Dullbuilderman26 11 — 3y
0
No problem! Glad I could help. Warphi 51 — 3y
Ad

Answer this question