001 | local mesh = script.Parent.Mesh |
002 | local music = script.Parent.Music |
003 | local playingmusic = false |
004 |
005 | function choosemusic() |
006 | music.Volume = 0.1 |
007 | music.TimePosition = 0 |
008 | local song = math.random( 1 , 12 ) |
009 | if song = = 1 then |
010 | music.SoundId = "rbxassetid://406637473" |
011 | end |
012 | if song = = 2 then |
013 | music.SoundId = "rbxassetid://406637473" |
014 | music.TimePosition = 1 |
015 | end |
This is the whole code for the radio and at the bottom is where I want it to be able to turn off and on again (Sorry for wasting you're time i'm just new and have no clue what to do)
Did you get the off() and on() functions mixed up? the off() function is playing the music whilst the on() function is stopping the music.
Hello, my name is NinjaManChase and I'll try to answer your question as simply as possible :)
It appears that you never toggled isOn
. This means that the script always thinks your radio is offline.
We can fix your code by replacing your onClicked function with:
01 | function OnClicked() |
02 |
03 | if IsOn then |
04 | isOn = false |
05 | off() |
06 | else |
07 | isOn = true |
08 | on() |
09 | end |
10 | end |
Hope this helped! Leave a comment if you need further assistance