I have a script to change values, which works on one car but not on the other. The script is meant to make a lightbar light up. The lights, who are located inside another model within the car, have their own script which works.
UPDATE I believe this is the problem:
local isOn = false veh = game.Workspace:FindFirstChild(script.Parent.Parent.CarName.Value, true) function on() isOn = true veh.lightbar1.on.Value = false end function off() isOn = false veh.lightbar1.on.Value = true end function onButtonClicked() if isOn == true then off() else on() end end script.Parent.MouseButton1Click:connect(onButtonClicked) on()
local isOn = false veh = script.Parent.Parent.CarName.Value function on() isOn = true veh.Value = false end function off() isOn = false veh.Value = true end function onButtonClicked() if isOn == true then off() else on() end end script.Parent.MouseButton1Click:Connect(onButtonClicked)
@DinozCreates
This should work like a toggle switch as long as the Variable is correct and you've got it placed in the correct location.
veh = script.Parent.Parent.CarName.Value function onButtonClicked() veh.Value = not veh.Value end script.Parent.MouseButton1Click:Connect(onButtonClicked)