How can I check if a part is NOT a child of a specific model?

So I made a script that detects if any of the parts in the character are touched, it checks if the part it touched is a certain velocity, then it kills the player. But when I fall, the character touches its own limbs, killing itself. To fix this, I tried to check if the part it touched it not in the player’s character, but somehow it just doesn’t kill the player at all. Here is my code so far:

wait(0.5)
local player = game.Players.LocalPlayer
local char = script.Parent
char.Torso.Neck.Enabled = false --ignore this
for _, part in pairs(script.Parent:GetChildren()) do
	if part:IsA("BasePart") and part.Parent then
		part.Touched:Connect(function(part1)
			if part1.Velocity.Magnitude >= 50 and part1.Parent ~= char then
				char.Humanoid.Health = 0
			end
		end)
	end
end

and it is in a local script in starter character scripts

wait(0.5)
local player = game.Players.LocalPlayer
local char = script.Parent
char.Torso.Neck.Enabled = false --ignore this
for _, part in pairs(script.Parent:GetChildren()) do
	if part:IsA("BasePart") then
		part.Touched:Connect(function(part1)
			for _, part2 in pairs(script.Parent:GetChildren()) do
				if part1.Velocity.Magnitude >= 50 and part2.Parent ~= part1.Parent then
					char.Humanoid.Health = 0
				end
			end
		end)
	end
end
1 Like