How would i make a text label number go up once a part is clicked?

so here’s what im trying to achieve, if i click a part i want the number of the text label to go up

picture explaining what i want to achieve

Basically, add a click detector and a script in the part
then write this in the script:

--//Variables

local numVal = 0

--//Click detector

script.Parent.ClickDetector.MouseClick:Connect(function(plr)

numVal += 1 --numVal increaces

plr.PlayerGui.ScreenGui.TextLabel.Text = numVal --TextLabel changes text to numVal (the number)

end)
1 Like

I think it’s simpler to do this,

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	local label = plr.PlayerGui.ScreenGui.TextLabel
	label.Text = tonumber(label.Text) + 1
end)

Assuming the default text of the Textlabel is a number

2 Likes