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

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

Asked by 3 years ago

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?

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. Voltaicmimic 43 — 3y
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 Xx0966xX 41 — 3y
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 User#44235 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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

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 Xx0966xX 41 — 3y
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 User#44235 0 — 3y
0
alright np could you just accept my answer so I get the points please lol Xx0966xX 41 — 3y
Ad

Answer this question