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

Why is my Radio playing the songs since I didn't insert the Disc decal? *Video included*

Okay. Last time I asked the question, it was closed because I wasn't specific. My script isn't functioning like I want it to do. What I am trying to do is click the CD to Insert the CD and if the texture on the CD is Uptown Funk, then it will play Uptown Funk then. As in whatever the decal is on the CD, will play that song after clicking on. Here is the video of what it looks like and how it is messed up and not functioning like I wanted it to do. And the script of it.

https://twitter.com/BTKB_RBLX/status/1017640784722571264

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://235468324"
            arrow.Rotation = Vector3.new(90, 45.631, -180) -- Turn to turn the music on
            sound:Play() --Play it
        elseif radioOn then
            disc.Texture = "rbxassetid://98698696" --Gangnam Style
            sound.SoundId = "rbxassetid://130844430" --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)

4 comments

0

The parent parameter of Instance.new is deprecated, assign the parent in another line. connect is deprecated, switch to Connect.

0

Will that even work? Is it just from connect to Connect?

0

It isn’t the problem, but deviating from deprecated code is always good practice.

0

I saw the link of it, but it is something I am not familiar with or even know how to do.

1 answer

I think your if statements are your problem. If the radio is off turn it on and play uptown funk else if it is on play gangnam style else if it is on (this will never run because it is the same as the last if) stop the music.

4 comments

0

so basically click it once it will play uptown click it anymore and it will play gangnam

0

So how would I stop that then?

0

Have a variable called radioMode. if radioMode == 1, play song 1; if radioMode ==2, play song 2; if radioMode == 3, turn off

0

As in add the variable, or would I have to replace a variable

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