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

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

Asked by 5 years ago

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)

0
The parent parameter of Instance.new is deprecated, assign the parent in another line. connect is deprecated, switch to Connect. User#19524 175 — 5y
0
Will that even work? Is it just from connect to Connect? RobotChitti 167 — 5y
0
It isn’t the problem, but deviating from deprecated code is always good practice. User#19524 175 — 5y
0
I saw the link of it, but it is something I am not familiar with or even know how to do. RobotChitti 167 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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.

0
so basically click it once it will play uptown click it anymore and it will play gangnam justoboy13 153 — 5y
0
So how would I stop that then? RobotChitti 167 — 5y
0
Have a variable called radioMode. if radioMode == 1, play song 1; if radioMode ==2, play song 2; if radioMode == 3, turn off ScrewDeath 153 — 5y
0
As in add the variable, or would I have to replace a variable RobotChitti 167 — 5y
Ad

Answer this question