Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to make a "if not touching anything then" statement?

So I am making a destructible car, and I am making a script that prevents any bricks from levitating.

I need a "if not touched then" statement. I searched for an hour or 2, and I couldn't find anything I need.

Here is my script, but its the opposite of what I want:


local function onTouch(otherPart) print("test1") script.Parent.WeldConstraint:Destroy() -- this is the thing i want it to do when not touching
--any parts at all end

script.Parent.Touched:Connect(onTouch)


Sorry for any bad spelling errors, or the fact that I can't make a good script, I am a noob in both lua and english.

1 answer

✓ Accepted answer

Why not make a filter to filter what parts can damage your car? like this:

car part.Touched:Connect(function(touchedpart)
	if touchedpart is named car part, then return false
	else 
	car part.Anchored = false or whatever damage system you are using
end)

1 comment

0

Thanks, I will try to use this!

This discussion is preserved as it was. New answers, comments, and votes are closed.