Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why won't the sound start playing?

Asked by 5 years ago
Edited 5 years ago

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
0
:IsA("BasePart"), use :GetDescendants() too, it allows you to stretch your iteration  Ziffixture 6913 — 5y
0
do Sound.IsPlaying instead of Sound.Playing Asytrion 11 — 5y
0
do Sound:Play() instead of Sound.Playing ihatecars100 502 — 5y
0
it didn't stop playing when i died PaliKai13 92 — 5y

Answer this question