Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I set a new intvalue on touch? [closed]

Asked by 5 years ago

How am I able to set a new intvalue? I have a certain value and that value is 1 I want to 1 to change to 2 on a touch based function. How would I do that?

0
Do you mean just counting up every time a part is touched? RyanTheLion911 195 — 5y

Closed as Not Constructive by hiimgoodpack and Fifkee

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 5 years ago

Remember that this isn't a request site, but as it was only a small request I will be happy to do it.

I was completely unsure of what you meant as your question contained very little detail, but I just made it so that when a part is touched it will change a value to 2. I also added a debounce so that the code will not run multiple times. Here is the code that I put together.

Code:

local intvalue = 1
local debounce = false

script.Parent.Touched:Connect(function()
    if not debounce then
        debounce = true
        intvalue = 2
        wait(5)
        debounce = false
    end
end)

Please accept my answer if this is the code that you wanted. :)

1
You're encouraging requests. hiimgoodpack 2009 — 5y
Ad