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

an error happening when i was trying to make an audio play. any fix?

I was trying to make an audio play when the player would press a button but I get an error saying "PlayLocalSound Is Not A Valid Member Of Sound." And im not sure how to fix this error. Here is the code

sound = script.Parent
	 
	function onKeyPress(inputObject, gameProcessedEvent)
		    if inputObject.KeyCode == Enum.KeyCode.Q then
			        sound:Play()
			    end
		end
	 
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

Does anyone know how to fix this error?

3 comments

0

I tried replicating this with your exact code, and it worked just fine. I placed the sound inside of a screengui (because why not), and then the script inside the sound. I pressed Q while in the game, and it worked. I used a LocalScript btw and I'm not sure if that's what you're using or not.

0

its the script the sound is played by Sound.Playing = True he using sound:Play() it took me a while to see it lol

0

im sorry for you responding I Have fixed it. And i guess it was just a studio issue. It has been resovled. Thank you

1 answer

Put the sound in the script not the script in the sound and put the script inside PlayerStarterScripts

3 comments

0

MY BAD Sorry didn't read your script right thats not how you play a sound its "Sound.Playing = True" you use ":Play()" when you playing a animation or tween

0

im sorry for you responding I Have fixed it. And i guess it was just a studio issue. It has been resovled. Thank you

0

alright np could you just accept my answer so I get the points please lol

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