I am making a counter which adds up when you click on a button. It uses a IntValue as a holder for how many times you have clicked.
What do you want to achieve? A counter.
What is the issue? It won’t add/subtract.
What solutions have you tried so far? I have tried debouncing and other things. I may have missed some details or I may have done something wrong. There is no error showing (I am new and so sorry for cringe code)
For now, it looks like this inside the button
-- local script lololol
local count = script.Parent.Parent.Parent.tick
local label = script.Parent
-- label is the button, i just reused my code
label.MouseButton1Click:Connect(function()
count.Value = count.Value + 1
end)
Hi there. What object class is label? Assuming it is a TextLabel based on the name, TextLabels do not have any event named MouseButton1Click as they cannot be clicked or pressed.
And there’s your answer. LocalScripts do not run when used as a descendent to the workspace. Use it under a local service instead such as StarterPlayerScripts and correctly re-reference your button and that’ll be your fix.
False assumption that the LocalScript was a descendant of workspace.
Please disregard my comment on the workspace placement then. StarterGui is completely fine location for LocalScripts and you do not need to replace the code to StarterPlayerScripts.
I believe it’d help to point that out that contents of StarterGui get automatically cloned and parented to your LocalPlayer.PlayerGui folder when you connect. So while observing value changes on the explorer, make sure you’re not checking the StarterGui, but the PlayerGui objects instead.
For the value update to the TextLabel, how is the TextLabel being updated?
It checks the IntValue if it gets changed by tick.Changed (i reuse my own code way too much sorry) and changes appropriately by the value of the IntValue.
And also the IntValue is in the StarterGui folder so maybe that’s the reason why it won’t update.