I made a script where I click the button and it supposed to move back 0.2 of the z axis which mean the music should be on, and if I click it again it is supposed to come back to normal as in come back adding 0.2 and then the music stops. It also determines to turn on if the decal is in the id I put in. Well, the problem is that I tested it and it worked on the first time, but it didn't move back or anything, and it also didn't start the sound after the second time. This is the script:
button = game.Workspace.Buttons.Button1
disc = game.Workspace.PlainDisc3.Decal
sound = Instance.new("Sound", disc)
radioOn = false
function onClicked()
if not radioOn and disc.Texture == "rbxassetid://238387775" then
radioOn = true
sound.SoundId = "rbxassetid://210232032"
sound:Play()
button.Position=button.Position-Vector3.new(0, 0, -0.2)
if radioOn and sound.SoundId == "rbxassetid://210232032" then
button.Position=button.Position+Vector3.new(0, 0, -0.2)
sound:Stop()
radioOn = false
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
I hope you understand
