Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Sound Play on-touch script help?

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?

1 answer

✓ Accepted answer
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

4 comments

1

Thank you so much!

1

Yup.

0

Estomac tell him what he did wrong don't just give him the answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.