So I have a script in my race car that, when this part is sticking out hits a part that is unanchored, it will play an audio saying "On your outside!" but no matter what I try, me and my friend cannot get it to work. https://gyazo.com/ab002f7edc57a0b61e47270309c7a5e6 ^ That is the picture
You have to be more specific on line 2. You are checking if hit.Parent is a player's character. There are properties in each object such as ClassName and Name. A character's class is not Body, nor is it his/her name. That's why it's best to check if hit.Parent has a child called "Humanoid" because only players in the server have Humanoids since it gives them health.
function onTouched(hit) if hit.Parent:FindFirstChild("Humanoid") then script.Parent:Play() end end script.Parent.Touched:Connect(onTouched) -- I'm puzzled about this line because on line 3, you want the script's parent to play so it is most likely a Sound. Here, you are giving this Sound a Touched event. Sounds cannot be touched and that's why they can't have Touched events. You either made a mistake on line 3 or here. Fix this too.