x.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Part") then x:Destroy() end --Part Destroy
I have this so my my part (x) deletes after touching another part, but for some reason its also deleting after touching terrain. Maybe part and terrain are both considered parts but either way, i dont want my part to delete when touching terrain, only parts. Thanks.
The reason for this is you do not have a system that is seeing if it is touching a player. So you part thinks that whatever it touches should be destroyed. A way to do this is finding the player and finding out if it exists. here is an example:
script.Parent.Touched:Connect(function(touched) local player = game:GetService("Players"):GetPlayerFromCharacter(touched.Parent) if player then script.Parent:Destroy() end end)
This script checks to see if a player touched the part before deleting.