Hello there!

I am relatively new into this so I deeply apologise. What I am trying to archive is to create a button that allows to play several loops located at distinct parts of the game. Or in other words, a group of civil defense sirens scattered over place game that can be activated from a single button.

For now, I have only been able to create a basic button that allows to play a loop located inside the same block the script and ClickDetector are placed. For which I used the following script;

local isOn = false

function on()
	isOn = true
	script.Parent.Loop:Stop()
end

function off()
	isOn = false
	script.Parent.Loop:Play()
end

function onClicked()
	
	if isOn == true then off() else on() end

end

script.Parent.Parent.ClickDetector.MouseClick:connect(onClicked)

on()

I'll be greatly thankful for anyone who can help me, Have a nice day!

1 comment

0

Are you trying to set of different loops that are inside of Scripts? If you are I suggest using IntValue.