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

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

Asked by 5 years ago

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

Log in to vote
0
Answered by
asgm 109
5 years ago

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)
0
Thanks, I will try to use this! george2006_1 0 — 5y
Ad

Answer this question