I have two scripts for the remote control. I made one script as the on/off switch and the other script to function the other buttons. Well, I turned it on and off and it works, but the buttons goes down and down. As in when I turn it on, I turn the shoot button on. Then I turn the button off, and click the button again. It doesn't work. Which is what I wanted it to do. But when I clicked on again, and clicked the shoot button on, it went down rather than back up where it is supposed to be. I guess I want it to where if I did turn it off it resets back to normal. I hope my scripts, pictures and video help out and clear out any confusion. I am horrible at explaining. Thank you for helping me!
Link to the pictures: https://imgur.com/a/TWXOWO6
Video: https://twitter.com/BTKB_RBLX/status/1017648043489943553
-- On/Off Button to Enable/Disable the Main Script --
Switch = script.Parent.Parent.Switch
switchOn = false
local onoff = game.Workspace.RemoteControl.Pad.Main
function onClicked()
if not switchOn then
switchOn = true
Switch.CFrame = Switch.CFrame+Vector3.new(0,-0.09,0)
Switch.BrickColor = BrickColor.new("Shamrock")
onoff.Disabled = false -- Enabling the script
elseif switchOn then
switchOn = false
Switch.CFrame = Switch.CFrame+Vector3.new(0,0.09,0)
Switch.BrickColor = BrickColor.new("Bright red")
onoff.Disabled = true -- Disabling the script
end
end
script.Parent.Parent.Switch.ClickDetector.MouseClick:Connect(onClicked)
This is the main script!
-- Up Button --
up = script.Parent.Parent.Up
upOn = false
function onClicked()
if not upOn then
upOn = true
up.CFrame = up.CFrame+Vector3.new(0,-0.09,0)
wait()
up.CFrame = up.CFrame+Vector3.new(0,0.09,0)
upOn = false
end
end
script.Parent.Parent.Up.ClickDetector.MouseClick:Connect(onClicked)
-- Down Button --
Down = script.Parent.Parent.Down
downOn = false
function onClicked()
if not downOn then
downOn = true
Down.CFrame = Down.CFrame+Vector3.new(0,-0.09,0)
wait()
Down.CFrame = Down.CFrame+Vector3.new(0,0.09,0)
downOn = false
end
end
script.Parent.Parent.Down.ClickDetector.MouseClick:Connect(onClicked)
-- Left Button --
Left = script.Parent.Parent.Left
leftOn = false
function onClicked()
if not leftOn then
leftOn = true
Left.CFrame = Left.CFrame+Vector3.new(0,-0.09,0)
wait()
Left.CFrame = Left.CFrame+Vector3.new(0,0.09,0)
leftOn = false
end
end
script.Parent.Parent.Left.ClickDetector.MouseClick:Connect(onClicked)
-- Right Button --
Right = script.Parent.Parent.Right
rightOn = false
function onClicked()
if not rightOn then
rightOn = true
Right.CFrame = Right.CFrame+Vector3.new(0,-0.09,0)
wait()
Right.CFrame = Right.CFrame+Vector3.new(0,0.09,0)
rightOn = false
end
end
script.Parent.Parent.Right.ClickDetector.MouseClick:Connect(onClicked)
-- Fly Switch Button --
Fly = script.Parent.Parent.FlySwitch
flyOn = false
function onClicked()
if not flyOn then
flyOn = true
Fly.CFrame = Fly.CFrame+Vector3.new(0,-0.09,0)
Fly.BrickColor = BrickColor.new("Shamrock")
elseif flyOn then
flyOn = false
Fly.CFrame = Fly.CFrame+Vector3.new(0,0.09,0)
Fly.BrickColor = BrickColor.new("Bright red")
end
end
script.Parent.Parent.FlySwitch.ClickDetector.MouseClick:Connect(onClicked)
-- Shoot and Activate Button --
AS = script.Parent.Parent.ActivateShoot
asOn = false
Shoot = script.Parent.Parent.Shoot
shootOn = false
function onActivateClicked()
if not asOn then --if asOn is off, turn it on
asOn = true
AS.CFrame = AS.CFrame+Vector3.new(0,-0.09,0)
AS.BrickColor = BrickColor.new("Shamrock")
--other code
elseif asOn then --if asOn is on, turn it and shootOn off
asOn = false
AS.CFrame = AS.CFrame+Vector3.new(0,0.09,0)
AS.BrickColor = BrickColor.new("Bright red")
--other code
shootOn = false
end
end
function onShootClicked()
if asOn then
Shoot.CFrame = Shoot.CFrame+Vector3.new(0,-0.09,0)
Shoot.BrickColor = BrickColor.new("Shamrock") --shoot code
wait()
Shoot.CFrame = Shoot.CFrame+Vector3.new(0,0.09,0)
Shoot.BrickColor = BrickColor.new("Bright red")
end
end
script.Parent.Parent.ActivateShoot.ClickDetector.MouseClick:Connect(onActivateClicked)
script.Parent.Parent.Shoot.ClickDetector.MouseClick:Connect(onShootClicked)
-- Laser and Activate Laser Button --
cals = script.Parent.Parent.ActivateLaserShooter
calsOn = false
Laser = script.Parent.Parent.LaserShooter
laserOn = false
function oncalsClicked()
if not calsOn then --if asOn is off, turn it on
calsOn = true
cals.CFrame = cals.CFrame+Vector3.new(0,-0.09,0)
cals.BrickColor = BrickColor.new("Shamrock")
--other code
elseif calsOn then --if asOn is on, turn it and shootOn off
calsOn = false
cals.CFrame = cals.CFrame+Vector3.new(0,0.09,0)
cals.BrickColor = BrickColor.new("Bright red")
--other code
laserOn = false
end
end
function onLaserClicked()
if calsOn then
Laser.CFrame = Laser.CFrame+Vector3.new(0,-0.09,0)
Laser.BrickColor = BrickColor.new("Shamrock") --shoot code
wait()
Laser.CFrame = Laser.CFrame+Vector3.new(0,0.09,0)
Laser.BrickColor = BrickColor.new("Bright red")
end
end
script.Parent.Parent.ActivateLaserShooter.ClickDetector.MouseClick:Connect(oncalsClicked)
script.Parent.Parent.LaserShooter.ClickDetector.MouseClick:Connect(onLaserClicked)
Sorry for the confusion. It is a long script, but you guys are smarter and know more than me. Thanks for helping me!

3 comments
Why are you creating new onClicked functions ?
What do you mean new onClicked functions? Isn't that how you supposed to do it?
No. Lines 5, 21, 37, 53, and 69 create a new onClicked function. Line 69 overwrites line 5, 21. 37, and 53 because it was assigned last.