I’ve been trying to make a simple script, it should change the text of a sign to match with the number of times you have clicked a button.
I tried to make the script, but I do not know how to change the text matching the local
text = “You have clicked CurrentCount times!” --It does not detect CurrentCount as the local, because it’s between the comas and it appears as text
Here’s the script so far:
Base = game.Workspace.CountingButton.Base
ClickZone = game.Workspace.CountingButton.ClickZone
ClickDetector = game.Workspace.CountingButton.ClickZone.ClickDetector
text = game.Workspace.CountingSign.TextZone.SurfaceGui.TextLabel.Text
text = “You have clicked 0 times!”
local CurrentCount = 0
ClickDetector.MouseClick:Connect(function()
local CurrentCount = CurrentCount +1
wait(0.1)
text = “You have clicked CurrentCount times!”
end)
The result of the above is the sign starting with “You have clicked 0 times” as text, and once the button is clicked, the text changes to “You have clicked CurrentCount times!”
Searched for this but couldn’t find any awnser, thanks!
Now the text is a number instead of CurrentCount, yet the number is always 0, I’m not sure why as the text should update each time the button is clicked.
Though at least now I know how to add the variable into the text, thanks for that!
You keep redefining CurrentCount as a new variable, instead of updating the old one.
local Base = game.Workspace.CountingButton.Base
local ClickZone = game.Workspace.CountingButton.ClickZone
local ClickDetector = game.Workspace.CountingButton.ClickZone.ClickDetector
local CurrentCount = 0
ClickDetector.MouseClick:Connect(function()
CurrentCount += 1 -- increment the number
game.Workspace.CountingSign.TextZone.SurfaceGui.TextLabel.Text = string.format("You have clicked %d times!", CurrentCount)
end)