Why won't the sound start playing?

local model  = script.Parent.Parent
local sound = script.Parent

local function onTouched(Part)
	if Part.Parent:FindFirstChild("Humanoid") and sound.IsPlaying == false then
		sound.TimePosition = 0
		sound:Play()
		repeat
			if sound.IsPlaying == true then
				Part.Parent:FindFirstChild("Humanoid").Died:connect(function()
					sound.Playing = false
				end)
			end
		until sound.IsPlaying == false
	end
end

for i, v in pairs(model:GetChildren()) do
    if v:IsA('BasePart') then
        v.Touched:Connect(onTouched)
    end
end

4 comments

0

:IsA("BasePart"), use :GetDescendants() too, it allows you to stretch your iteration 

0

do Sound.IsPlaying instead of Sound.Playing

0

do Sound:Play() instead of Sound.Playing

0

it didn't stop playing when i died