I am currently making a drone and want to script it so it will be removed if it collides with another part.
The one thing I have tried so far is
script.Parent.Part.Touched
However I am aware that this only functions if a player hits it. Is there any alternative away that will function if the Brick collides with another brick?
Thanks.
The event .Touched activates when a part touches a part, and of course all players have a character full of parts. However, they are linked from player to character and vice versa. Here are some methods:
An if statement detecting humanoids:
targetPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildWhichIsA('Humanoid')==nil then
print('hit detects no humanoid')
end
end)
An if statement detecting player's character:
targetPart.Touched:Connect(function(hit)
if game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)==nil then
print('hit is not a part of a character')
end
end)