I am making a script where If you touch a block It plays music and when you leave it the music stops kinda like a sound region or area music. But the problem is that it doesn't stop when the player gets out of the area, meaning that the audio does play but doesn't stop when the player exits the area. This Is the script:
local part = script.Parent
local sound = part:FindFirstChild("Sound")
local function music(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if humanoid then
sound:Play()
if not humanoid then
sound:Stop()
end
end
end
part.Touched:Connect(music)
####Reformed by JesseSong (Fixed grammatical errors)

2 comments
OOPS, line 06, 09, and 10 should be deleted OR IT MIGHT GLITCH!
It doesn't work :(