I am developing a plane in which when you sit in the the seat it plays an audio. I have figured out how to make the audio play... but it will not loop. Here's my script that I need help with. What should I do? Thank you.

local sp = script.Parent

sp.ChildAdded:connect(function(weld)
    I = Instance.new("Sound", Workspace)
    I.SoundId = "http://www.roblox.com/asset/?id=142317661"
    I.Volume = 1.0
    I.Pitch = 1.1
    I:Play()
    while true do 
        if not sp:findFirstChild(weld.Name) then 
            I:Stop()
            I:Destroy()
            break
        end
        wait()
    end
end)


2 comments

0

Remember, try to replace infinite loops with events. In this case, you can, but I'll give you a challenge to see if you know what event to use.