I have a (very wonky) damage system for a car, hitbox touches a thing, checks if it has CanCollide on and Anchored on, then it takes the appropriate steps to break the part off of the car, there's one issue though, if there's a part that's set to not collide through a collision group, and it will still break off, since it's set to check for cancollide and anchored (say, a player with an anti player-car collide script)
here's a code sample: (i'm sure it's scuffed in a way so if you want to comment on that go right ahead)
script.Parent.Transparency = 1
local frontwing = script.Parent.Parent:FindFirstChild("Front wing")
local children = frontwing:GetDescendants()
script.Parent.Touched:Connect(function(touched)
if touched.AssemblyLinearVelocity.Magnitude <= 5 and touched.CanCollide == true and script.Parent.AssemblyLinearVelocity.Magnitude >= 50 then
script.Disabled = true
for i, child in ipairs(children) do
if child:IsA("BasePart") then
child:BreakJoints()
child.CanCollide = true
local weld = Instance.new("WeldConstraint")
weld.Part0 = child
weld.Part1 = frontwing.BottomPart
weld.Parent = child
end
end
script.Parent.Parent.Parent.DownforceF:BreakJoints()
script.Parent.Parent.Parent.DownforceF.Anchored = true
end
end)
to sum up what i want to do:
I want to make it so it will also check if the part it's touching actually collides with it instead of just moving through it (and breaking the part off) while being set to not collide with a collision group, that's pretty much all
Any help greatly appreciated!
