Let's say that I made a hitbox. Five parts are touching the hitbox. Each part will be touched only once. If the hitbox touches that part again, the code wouldn't run on it. Are there any efficient ways of doing that?
You can have a variable for each part called, for example, "enabled". You can default the variables to true. In the Touched
event, you can check if the variables are true using if statements. Then, inside of the if statements, after the rest of your code, set the variables to false. This way, the code will only run the first time the part is touched. Your code would look something like this:
local enabled = true part.Touched:Connect(function() if enabled then --code enabled = false end end)