I am using a boolvalue and a sound and a clickdetector. I am trying to make it so when I press the siren [i am making a police car] a siren sound plays. I got the script as a free model but i had to edit it since it meant that I could only play it not stop / pause it.
Brick = script.Parent Sound = Brick.Sound function onClicked() Sound:Play() script.Parent.Value.Value = true end function onClicked() if script.Parent.Value.Value = true then Sound:Stop() else end script.Parent.ClickDetector.MouseClick:connect(onClicked)
here is the hierachy Part Sound Clickdetector Value (boolvalue) Script
The worst thing for me is that I cannot find any decent place to help me start learning to script! thanks
it can be done a lot easier by doing a check on the IsPlaying property
script.Parent.ClickDetector.MouseClick:Connect(function() if Sound.IsPlaying then Sound:Stop() -- or Sound:Pause() else Sound:Play() -- or Sound:Resume() end end)
I don't know weather this helps, but try this:
script.Parent.ClickDetector.MouseClick:connect(function() if script.Parent.Value.Value == false then script.Parent.Sound:Play() script.Parent.Value.Value = true else script.Parent.Sound:Stop() script.Parent.Value.Value = false end end)