I made a script in which I press a button and then it makes a noise, and then another noise. Here's my script:
01 | local Switched = script.Parent.Switched |
02 |
03 | function onClicked() |
04 |
05 | if Switched = = false then |
06 | Switched = true |
07 | script.Parent.On:Play() |
08 | wait( 0.5 ) |
09 | script.Parent.Off:Play() |
10 | wait( 0.2 ) |
11 | Switched = false |
12 | end |
13 |
14 |
15 | end |
16 |
17 | script.Parent.ClickDetector.MouseClick:connect(onClicked) |
Here's a nice fix;
01 | local Switched = false -- You can't change a Objects value. Unless Switch is a BoolValue |
02 | local CD = script.Parent:WaitForChild( 'ClickDetector' ) --The ClickDetector |
03 | local On = script.Parent:WaitForChild( 'On' ) --On |
04 | local Off = script.Parent:WaitForChild( 'Off' ) -- Off |
05 | CD.MouseDown:Connect( function () --You can use MouseDown |
06 | if Switched = = false then |
07 | Switched = true |
08 | On:Play() |
09 | wait( 0.5 ) |
10 | Off:Play() |
11 | wait( 0.2 ) |
12 | Switched = false |
13 | end |
14 | end ) |
This should work, though I was not sure what Switched Was because there was no value.
If this helped then please accept answer :D