What I'm trying to do is when the player clicks a brick a GUI in the corner of there screen will add by 1
The number is not changing and there is no error in the output
Count = 0 Collect = script.Parent function OnClicked() Count = Count + 1 game.StarterGui.ScreenGui.TextLabel.Text = Count end Collect.ClickDetector.MouseClick:Connect(OnClicked)
What you're doing wrong is you are changing the value in the starter gui instead of the player gui. What you need the script to read is down below:
local Count = 0 local Collect = script.Parent function OnClicked(player) Count = Count + 1 player.PlayerGui.ScreenGui.TexxtLabel.Text = Count end Collect.ClickDetector.MouseClick:Connect(OnClicked)
the reason I typed player in the parentheses if because the listeners of the MouseClick
event get us the player that clicked the part, so all we need to do is change the text from there.
Hope I helped.