Playing is not a valid member of part?

Currently adding sound to my lockdown system and it says…
image

I’m unsure of why this is happening other than maybe a GetChildren:() error?

local LockdownButton = script.Parent
local clickDetector = LockdownButton.ClickDetector
local clicked = false
local lights = game.Workspace.Lights
local SoundParts = game.Workspace.SoundParts

function onMouseClick()
	if not clicked then 
		clicked = true 
		LockdownButton.BrickColor = BrickColor.Red()
		for k, Sound in pairs(SoundParts:getChildren()) do
			wait()
			Sound.Playing = true
			wait(9)
			Sound.Playing = false
			end
			for k, light in pairs(lights:getChildren()) do
			wait()
			light.Light.Color= Color3.fromRGB(255, 58, 58)
			end
	else 
		clicked = false 
		LockdownButton.BrickColor = BrickColor.Green()
		for k, light in pairs(lights:getChildren()) do
			wait()
			light.Light.Color= Color3.fromRGB(255, 255, 255)
		end

	end
end

clickDetector.MouseClick:connect(onMouseClick)

(The error is on line 13)

Is sound supposed to be a sound instance?

Yes it is supposed to be a Sound Instance.

Can I see your studio explorer setup?

image

Couldn’t get it to do just

game.SoundService.Sound.Playing = true 

Since you couldn’t hear it

The sounds are attached to the Part instances, and you’re trying to play the Part itself, which is not a sound. Try this:

for k, Sound in pairs(SoundParts:getChildren()) do
    if Sound:FindFirstChild("Sound") then
	    wait()
	    Sound["Sound"].Playing = true
	    wait(9)
	    Sound["Sound"].Playing = false
    end
end

Try sound.sound it’s pointing to the parts.

local LockdownButton = script.Parent
local clickDetector = LockdownButton.ClickDetector
local clicked = false
local lights = game.Workspace.Lights
local SoundParts = game.Workspace.SoundParts

function onMouseClick()
	if not clicked then 
		clicked = true 
		LockdownButton.BrickColor = BrickColor.Red()
		for k, Sound in pairs(SoundParts:getChildren()) do
			wait()
			Sound.Sound.Playing = true
			wait(9)
			Sound.Sound.Playing = false
			end
			for k, light in pairs(lights:getChildren()) do
			wait()
			light.Light.Color= Color3.fromRGB(255, 58, 58)
			end
	else 
		clicked = false 
		LockdownButton.BrickColor = BrickColor.Green()
		for k, light in pairs(lights:getChildren()) do
			wait()
			light.Light.Color= Color3.fromRGB(255, 255, 255)
		end

	end
end

clickDetector.MouseClick:connect(onMouseClick)

Yes it does work but they don’t play at the same time, only after each one has finished playing

The ‘Sound’ isn’t the sound itself it’s the child part of soundParts.
This should work better like this
Sound.Sound.IsPlaying
Or
Sound.Sound.Playing

What a for loop does is iterate through the folder, not play them simultaneously.

What you should do is have two separate for loops, one to turn them all on, wait, then one to turn them all off.

PSEUDOCODE:

For all in folder do
     Turn sound on

Wait(9)

For all in folder do
     Turn sound off

I’ve solved it by just adding a new sound to workspace then setting the sound Id.