Sorry if this is really easy, but how do I make a variable get one more number in its value when it is touched? For example - triesUsed = 0 touches brick triesUsed = 1
I create this simple script:
Tries = 0 --The Value script.Parent.Touched:Connect(function() --Detect If It Touched Tries = Tries + 1 --Adding A Number To The Value wait() print(Tries) --Print The Value end)
Hope It Helps!
You could also use a NumberValue to make it able to be detected in multiple scripts.
Example:
local Value = Instance.new("NumberValue", script.Parent) -- script.Parent is the script's parent Value.Value = 0 wait = false -- Cooldown script.Parent.Touched:Connect(function() if wait == false then -- If the cooldown isn't active. wait = true -- Cooldown Active Value.Value = Value.Value + 1 wait(5) -- Change the 5 to how many seconds the cooldown you want to be. wait = false -- Stop the cooldown end end)
Hope this helped!