I wrote this script to show a problem I am having. When a humanoid touches this part it shows that the part is touched thousands of times. How would I rewrite this script so that when the part is touched by a humanoid, the function will run only once until retouched.
countNumber = 0
script.Parent.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid") ~= nil then
countNumber = countNumber + 1
print(countNumber)
end
end)

2 comments
thats really nasty code. just make a variable, this code will forever make me cry. you took the time to find a bool inside a player, and create one in a player that will work once... duuuuude, a simple boolean could have done the trick T_T
bruh Why make an object inside the player when you can just make a bool variable -_-