Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Looping is not a valid member of Sound?

Hi so I have this script in StarterGui

-- Local Script

cam = game.Workspace.CurrentCamera
minheight = -20.5 -- height (in studs) before it plays the deep sound
sound = script.Parent.CreakingNoises -- location of the sound (put it somewhere on the client like StarterGui)
deepsound = "rbxassetid://200404653" -- the sound of when the sub is deep
shallowsound = "rbxassetid://282286147" -- the sound of when the sub is in shallow

sound.Looping = true

while true do
    if cam.CoordinateFrame.Position.Y <= minheight then
        sound:Stop()
        sound.SoundId = deepsound
        sound:Play()
    else
        sound:Stop()
        sound.SoundId = shallowsound
        sound:Play()
    end
end

But it gives me this error Looping is not a valid member of Sound Has anyone got an idea what Im doing wrong?

1 answer

✓ Accepted answer

An easy fix, Looping is not an actual property of Sound. Its actually Looped


sound.Looped = true 

while true do
    if cam.CoordinateFrame.Position.Y <= minheight then
        sound:Stop()
        sound.SoundId = deepsound
        sound:Play()
    else
        sound:Stop()
        sound.SoundId = shallowsound
        sound:Play()
    end
end

https://developer.roblox.com/en-us/api-reference/class/Sound

This discussion is preserved as it was. New answers, comments, and votes are closed.