I asked this question a couple days ago, and I received one answer, but it did not work. I am going to try re-asking this question a little differently this time, to make sure I'm clear. So, I have a part, I made two scripts within the part and then wrote this in the first:
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
game.Players[hit.Parent.Name].PlayerGui.Sound:Resume()
end
end)
And this in the second:
script.Parent.TouchEnded:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
game.Players[hit.Parent.Name].PlayerGui.Sound:Pause()
end
end)
Obviously, this is not working. The answer I got suggested I use IsPlaying, so I wrote another script, which is this:
script.Parent.Touched:connect(function(hit)
if game.StarterGui.Sound.IsPlaying == false then
game.StarterGui.Sound:Resume()
end
end)
I don't know how to connect a statement for finding the humanoid and then use the IsPlaying statement. Anyways, every time I step within the part, it causes ridiculous lag, so I think the script must be running constantly, though I'm not sure. I want to just walk into the part, the sound plays, I walk out, the sound stops. I also would like it not to lag me ridiculously bad. Any advice or suggestions would be greatly appreciated. Thanks!
****EDIT: @SquirrelOnToast Figured out how to do it. Thanks for the help, but your suggestion ultimately did not work. I am very appreciative though of the time you took to help me out, it started me on the right trail, and ultimately it turned out to be very simple. I will mark your answer as accepted, though.

8 comments
First off, I thank you for your well thought out and detailed reply, I am tremendously grateful. Unfortunately, when entering the part, I still lag. Strangely enough, this happens ONLY on my custom character model, and not on a normal roblox model. Also, when on the regular roblox model, upon leaving the part, the music does not stop playing, and once i re-enter the part, it starts over.
Oh hang on, I forgot. Debounce. Also, I had lines 3 and 4 the wrong way round. Flip those around, and give this page a look. http://wiki.roblox.com/?title=Debounce
So, would I just add debounce like this?: script.Parent.Touched:connect(debounce(function(hit)
I read that page quite a few times, and I am still confused on how to apply it to this situation.
Just wanted to thank you again for your answer: thanks. If you reply to these comments I might just have to fall down at your feet and cry. This issue has been plaguing me since I started making this game, and it would be absolutely amazing to get it fixed. :D
It's a bit hard to fit in a comment; edited the main post
Forgive me for my noobness, but I tried to add debounce and now the sound won't play at all! It would seem to me if debounce = true before the function begins it would do nothing right? I'm really sorry to bother you again. :/
Problem lies with you not setting debounce to false at the end of your function.