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

Can someone tell me what is wrong in the scrip?

Asked by 6 years ago
Edited 6 years ago

This script should stop a sound that is playing whit the function "PlayLocalSound"



script.Parent.Touched:connect(function() if game.SoundService.Sound1.playing.Value == 1 then local stop = game.SoundService.Sound1:Stop() else end)

1 answer

Log in to vote
0
Answered by 6 years ago

Hi el_devil, I'm not sure what you're trying to do with this script but my best guess is that you're trying to make a script that stops playing a song when you touch it, then if you touch it again then it will turn back on? If I'm correct then try this:

sound = game.Soundscape.Sound1

db = true

script.Parent.Touched:connect(function()
    if db == true then
        db = false

        if sound.Playing == true then -- If it's playing then

            sound:Stop() -- stop the sound

        elseif sound.Playing == false then -- If it's not playing then

            sound:Play() -- play the sound

        end

        wait(1) -- amount of time until you can run the script again

        db = true
    end
end)

Again I'm not sure if that's what you're trying to do but it's my best guess.

0
You don't need == true, only sound.Playing, as an if statement counts a false bool as 'non-existing' kind of. Robin5D 186 — 6y
Ad

Answer this question