How To Disable/Enable Something When A Music Plays

I want to enable a script in the workspace when music plays and when it stops I want to disable the script again. Can someone help me?

It can be something like this -

local script = workspace.script
local music = workspace.music

if music.Playing = true then
script.Enabled = true
elseif
music.Playing = false then
script.Enabled = false

(My script doesn’t work)

use a .Changed function

local script = workspace.script
local music = workspace.music

music.Changed:Connect(function()
if music.Playing == true then
script.Enabled = true
else
script.Enabled = false
end
end)
1 Like

I believe someone else already asked a similar question. This may be of help to you.

I’d recommend using the search feature before posting a question just to see if perhaps someone had a similar question that’s already been answered. :slight_smile:

2 Likes