Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to make it that this sound block only making sound when a object with a special name hits it ???

Asked by 3 years ago
Edited 3 years ago
function onTouched(hit)
    script.Parent.Audio:play()
end
script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
0
Answered by 3 years ago

You check the name property of the object that hit it.

function onTouched(hit)
    if hit.Name == "SpecialName" then
      script.Parent.Audio:play()
    end
end
script.Parent.Touched:connect(onTouched)
0
thx :D spiderfliege 7 — 3y
Ad

Answer this question