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

Why does my button when clicked not register as event?

Asked by 3 years ago

For some reason, one of the simplest things isn't working. I am trying to make a button that when you click it, it subtracts a currency found in a GUI (Not advanced enough to make leaderboard cash, if you can help with this please tell me how.) However, when I click the button it does nothing! Even crazier, the button updates nothing at all, if I press it, it won't even register it as a click. Here is my the code:

script.Parent.MouseButton1Down:Connect(function() game.StarterGui.Money.TextLabel.Number.Value = game.StarterGui.Money.TextLabel.Number.Value - 10 end)

0
did you try printing something whenever the button is clicked User#34929 0 — 3y
0
Kinda, I did other tests (this is how i know it wasn't the code after clicking the button that was wrong) wolftamer894 50 — 3y
0
Thank you so much RaforawesomeAlt! This is the first time I have used this website. PS: You gave me motivation! wolftamer894 50 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

You're modifying the StarterGui. Changes in StarterGui apply when the player respawns and the gui is next cloned to them. you want to modify Player.PlayerGui instead, with something like game.Players.LocalPlayer.Money.TextLabel.Number.Value = "something" (assuming this is a LocalScript, like all gui scripts should be).

Ad

Answer this question