I made two parts. One as the turn on and off button and the other to click to shoot button. Well, the problem is that, every time I click it, it does go down, but instead when I hit the shoot button, the other button goes down rather than staying down. I want the ActivateShoot
part to be the on/off button for the other part. So let's say I turn on the ActivateShoot
button, what it should do is go down to the position that I put and function the Shoot
part. And if I click the ActivateShoot
part again, it will be off and the Shoot
part will not work, as in disabled unless you turn it back on. I hope I am being clear to what I am trying to do here. Sorry for the confusion!
-- Combining the Shoot and Activation -- AS = script.Parent.Parent.ActivateShoot asOn = false Shoot = script.Parent.Parent.Shoot shootOn = false function onClicked() if not asOn then asOn = true AS.CFrame = AS.CFrame+Vector3.new(0,-0.09,0) AS.BrickColor = BrickColor.new("Shamrock") shootOn = true Shoot.CFrame = Shoot.CFrame+Vector3.new(0,-0.09,0) Shoot.BrickColor = BrickColor.new("Shamrock") wait(0.05) Shoot.CFrame = Shoot.CFrame+Vector3.new(0,0.09,0) Shoot.BrickColor = BrickColor.new("Bright red") elseif asOn then asOn = false AS.CFrame = AS.CFrame+Vector3.new(0,0.09,0) AS.BrickColor = BrickColor.new("Bright red") shootOn = false end end script.Parent.Parent.ActivateShoot.ClickDetector.MouseClick:connect(onClicked) script.Parent.Parent.Shoot.ClickDetector.MouseClick:connect(onClicked)
Your Shoot
button is calling the same function as ActivateShoot
. When you click the Shoot
button while asOn
is on, it'll go to line 18 elseif asOn then
and make asOn
and shootOn
false.
You have two different commands, so you need to separate the instructions.
function onActivateClicked() if not asOn then --if asOn is off, turn it on asOn = true --other code elseif asOn then --if asOn is on, turn it and shootOn off asOn = false --other code shootOn = false end end function onShootClicked() if asOn then --shoot code end end script.Parent.Parent.ActivateShoot.ClickDetector.MouseClick:connect(onActivateClicked) script.Parent.Parent.Shoot.ClickDetector.MouseClick:connect(onShootClicked)