I want to make it so when a part collides that something happeens basically but I’m not sure how to do it and I’ve looked around but no solutions. I do have a touched event in place but that’s for when a player touches it that they’d get damaged/etc and if I did put what I wanted to be done in it then it’d happen everytime someone touches the part so how would I go about making it so when the part collides with the ground or anything that something would happen ONLY ONCE.
There are many ways you could do this. One way is to use a ‘debounce’ to make sure the code after the .Touched
event only runs once.
local debounce = false
local part = script.Parent
part.Touched:Connect(function(partTouched)
if debounce == false then
debounce = true
print("Test",partTouched)
end
end)
I made this in the text editor, not in studio, so it might be formatted/spaced wrong. The idea is what matters.