0

# Sound Play on-touch script help?

Asked by 7 years ago

I'm finding it hard to make a script, that allows each part named something, like for example grass, have a sound when you step on it. I made a script with a function, and well here it is: function touch(hit)

function touch(hit) if hit.Name == "Grass" then end end script.Parent.Touched:connect(touch) Workspace.sound.play() wait(1) Workspace.sound.play() wait(1) loop end

Please help me with this script, maybe find some errors, i don't want a link to a model, i need help. So am i doing anything wrong?

2
ImageLabel 1541
7 years ago
workspace.Part.Touched:connect(function(hit) -- .Touched
if hit.Name == "grass"  then
print("Nothx")
else
workspace.Sound:Play()
wait(1)
workspace.Sound.Looped = true --False if not supposed to loop
end
end)


--In order to loop the sound, you must set it's "Looped" property to true; Sound.Looped=true --Also, the sound in your code wouldn't play as you'd want since it's not connected to the event

1
Thank you so much! arjun9022 34 — 7y
1
Yup. ImageLabel 1541 — 7y
0
Estomac tell him what he did wrong don't just give him the answer raspyjessie 117 — 6y
0
Hey there, stranger. I hope you do realize the '6 months ago' label on this post. It's really not your place to tell me how to go about answering his question. I'm sure he would have asked for clarification if he wished. ImageLabel 1541 — 6y