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

Can someone resolve this script that involves SoundId and ImageId?

Asked by 6 years ago

It's been a while since I have been scripting or to even come to this site. Anyway, I am having trouble with getting the SoundId to play with the ImageId. Hope you know what I mean based on this script.

local arrow = game.Workspace.Arrow
local disc = game.Workspace.PlainDisc2.Decal
local sound = Instance.new("Sound", disc)
sound.SoundId = "rbxassetid://210232032"
debounce = false
radioOn = false

function onClicked() -- Clicked
    if not debounce then
        debounce = true

        if not radioOn then
            radioOn = true -- Turn Radio on
            disc.Texture = "rbxassetid://238387775" --Uptown Funk
            arrow.Rotation = Vector3.new(90, 45.631, -180) -- Turn to turn the music on
            sound:Play() --Play it
        if not radioOn then
            radioOn = true -- Turn Radio on
            disc.Texture = "rbxassetid://98698696" --Gangnam Style
            sound.SoundId = "rbxassetid://163211519" --Play Gangnam Style
            arrow.Rotation = Vector3.new(90, 45.631, -180) -- Turn to turn the music on
            sound:Play() --Play it
        elseif radioOn then
            disc.Texture = "" -- Set Disc texture to nothing
            radioOn = false -- Turn Radio off
            sound:Stop() --Stops the sound
            arrow.Rotation = Vector3.new(-90, -45.631, 0) --This arrow should go back before the disc is plain and radioOn is false
            print("Off\n".."PlainDisc") -- prints
        end

        debounce = false
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)



Thank you so much for the help!

0
What, are you trying to play a sound with an Id, being the Id of the decal? sodaghost1 34 — 6y
0
Yes @sodaghost1! I want it to where if I click it, it will play the sound with the image ID. RobotChitti 167 — 6y

1 answer

Log in to vote
0
Answered by 5 years ago

It is not playing the sound because you are...

  1. Changing the texture of a decal to a sound id. Don't know what you were thinking, this won't make anything appear.
  2. Not changing the SoundId of the sound.

To fix this, make sure you change the SoundId property of the sound and don't change the texture property of the decal unless it's an IMAGE you are changing it to.

Fixed script:

local arrow = game.Workspace.Arrow
local disc = game.Workspace.PlainDisc2.Decal
local sound = Instance.new("Sound", disc)
debounce = false
radioOn = false

function onClicked() -- Clicked
    if not debounce then
        debounce = true

        if not radioOn then
            radioOn = true -- Turn Radio on
            disc.Texture = "rbxassetid://238387775" --Uptown Funk
    sound.SoundId = "rbxassetid://210232032"
            arrow.Rotation = Vector3.new(90, 45.631, -180) -- Turn to turn the music on
            sound:Play() --Play it
        if not radioOn then
            radioOn = true -- Turn Radio on
            disc.Texture = "rbxassetid://98698696" --Gangnam Style
            sound.SoundId = "rbxassetid://163211519" --Play Gangnam Style
            arrow.Rotation = Vector3.new(90, 45.631, -180) -- Turn to turn the music on
            sound:Play() --Play it
        elseif radioOn then
            disc.Texture = "" -- Set Disc texture to nothing
            radioOn = false -- Turn Radio off
            sound:Stop() --Stops the sound
            arrow.Rotation = Vector3.new(-90, -45.631, 0) --This arrow should go back before the disc is plain and radioOn is false
            print("Off\n".."PlainDisc") -- prints
        end

        debounce = false
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)




On second thought, I don't really understand what you are asking. Hopefully I have answered your question, if I didn't tell me what you are still confused about.

0
Sorry for the confusion. This is what I am trying to do. I want it to where when I click the Arrow, it turns on, which is the position it goes to. The music will also turn on if the image on the disc is the same as the song. So if the disc has Uptown Funk texture on it then when I click it, it will play Uptown Funk. I am making a radio, but in a different way. Hope this clears it up :D RobotChitti 167 — 5y
0
This should work then. I do not know if your sound ids and image ids are accurate, though. Reading through the script quickly, everything seems alright. Operation_Meme 890 — 5y
Ad

Answer this question