Can somebody please help me fix this script.
The script is placed into a GUI on a vehicle which when a button is pressed the vehicle doors “should open” but they don’t I have set this up in a similar way the keyboard controls are setup.
I have provided both the button version (where I’m getting the attempt to call a nil value error)
and the keyboard controls version (which works fine)
Button version (attempt to call nil value) - this is for mobile players
script.Parent.Parent.Parent.Parent.FE_Events.BusControls.OnServerEvent:connect(function(Car)
function Clicked()
Car.Main.HingeDoors.Open.Value = not Car.Main.HingeDoors.Open.Value
end
end)
script.Parent.MouseButton1Click:connect(Clicked)
Keyboard controls version (works fine) - for PC/Xbox players [xbox controls are not show in the script however they are in the main script I have]
script.Parent.FE_Events.BusControls.OnServerEvent:connect(function(player, Car, exec)
if exec == Enum.KeyCode.L then
Car.Main.Headlights.Lit.Value = not Car.Main.Headlights.Lit.Value
elseif exec == Enum.KeyCode.Z then
Car.Main.HingeDoors.Open.Value = not Car.Main.HingeDoors.Open.Value
end
end)
As you can see they are basically the same the only difference is one is controlled by keyboard/controller input the other is controlled by buttons on a GUI but sadly the GUI button one doesn’t work.
Appreciate any help
Sorry if this sounds all confusing.