Hello, I want to make a brick with ClickDetector that can play the id '2315428899' only if turned on and stop playing when a player turn it off. I'm new at scripting, can someone help me?
COMMUNITY QUESTION
How can I scipt a brick with Clickdetector that can turn on/off the music?
1 answer
Here is the hierarchy I recommend you go with:
- A part is the parent of a ClickDetector, a Sound instance and a script.
Example script:
local sound = script.Parent.Sound
local bool = true
script.Parent.ClickDetector.MouseClick:Connect(function()
if bool == false then
sound:Pause() -- Music can be resumed
bool = true
end
if bool == true then
if not sound.Played then
sound:Play()
bool = false
elseif sound.Played then
sound:Resume()
bool = false
end
end
end)
This script plays the sound then checks to see if the sound was played before resuming it. It also pauses it if the debounce is false.
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
https://scriptinghelpers.org/help/community-guidelines https://scriptinghelpers.org/help/community-guidelines https://scriptinghelpers.org/help/community-guidelines https://scriptinghelpers.org/help/community-guidelines https://scriptinghelpers.org/help/community-guidelines https://scriptinghelpers.org/help/community-guidelines https://scriptinghelpers.org/help/community-guidelines
please someone?
this isn't technically a request...fine
.