Hello can someone maybe help with this,
I have a minecart but as u know you can turn it off or on, But i want it as if you turn the cart on you cant turn it off anymore.
Does someone know how this works?
function chng() script.Parent.Parent.CarOn.Value = not script.Parent.Parent.CarOn.Value if script.Parent.Parent.CarOn.Value == false then script.Parent.BrickColor = BrickColor.new(21) else script.Parent.BrickColor = BrickColor.new(28) end end
script.Parent.Click.MouseClick:connect(chng)
This is the code for the minecart button that will let it move
What you're doing is changing the CarOn BoolValue to it's opposite value. Everytime someone clicks the button and for example, the car is on, it will change to off, if the player clicks it again, it will change to on. There's your code, hope it helps u understand
function chng() local CarOn = script.Parent.Parent.CarOn --If the minecart is on, then don't do nothing if CarOn.Value == true then return elseif CarOn.Value == false then --But if the minecart is off, then set the car on CarOn.Value = true --Here you can script what you want to do when it turn on end end script.Parent.Click.MouseClick:connect(chng)