as the title suggests, the script seems unable to find the value and also seems to ignore my if statements.
The value is not nil and should be the same in the script.
task.wait(.1)
local IGNITION_KEYBOARD = Enum.KeyCode.F
local IGNITION_CONTROLLER = Enum.KeyCode.ButtonB
local UserInputService = game:GetService("UserInputService")
local gamepadPresent = UserInputService.GamepadEnabled
local veh = game.Workspace:FindFirstChild(script.Parent.Parent.Car.Value, true)
repeat task.wait() until script.Parent.Parent.Car.Value ~= nil
local function onInput(input:InputObject, gameProcessedEvent:boolean)
if gameProcessedEvent then return end
if not (input.KeyCode == IGNITION_KEYBOARD or input.KeyCode == IGNITION_CONTROLLER) then return end
if script.Parent.Parent.IsOn.Value and script.Parent.Parent.Car.Value ~= nil then
if input.UserInputState == Enum.UserInputState.End then return end
script.Parent.Parent.IsOn.Value = false
veh.DriveSeat.Ignition.IgnitionChange:FireServer("Off")
else
script.Parent.Parent.Starting.Value = input.UserInputState == Enum.UserInputState.Begin
end
end
local function update()
gamepadPresent = UserInputService.GamepadEnabled
script.Parent.Text = "Hold <i><stroke color='#000000' thickness='2'><font weight='900'>"..(gamepadPresent and IGNITION_CONTROLLER.Name or IGNITION_KEYBOARD.Name).."</font></stroke></i> to turn on."
script.Parent.Visible = not script.Parent.Parent.IsOn.Value
if script.Parent.Parent.IsOn.Value and script.Parent.Parent.Car.Value ~= nil then
print(veh)
veh.DriveSeat.Ignition.IgnitionChange:FireServer("On")
elseif script.Parent.Parent.Car.Value ~= nil then
print(veh)
veh.DriveSeat.Ignition.IgnitionChange:FireServer("Off")
end
end
UserInputService.InputBegan:Connect(onInput)
UserInputService.InputChanged:Connect(onInput)
UserInputService.InputEnded:Connect(onInput)
UserInputService.GamepadConnected:Connect(update)
UserInputService.GamepadDisconnected:Connect(update)
script.Parent.Parent.IsOn.Changed:Connect(update)
update()
Output:
22:25:24.236 Players.lenovo17101.PlayerGui.A-Chassis Interface.Ignition.Ignition:31: attempt to index nil with 'DriveSeat' - Client - Ignition:31
22:25:24.236 Stack Begin - Studio
22:25:24.236 Script 'Players.lenovo17101.PlayerGui.A-Chassis Interface.Ignition.Ignition', Line 31 - function onInput - Studio - Ignition:31
22:25:24.236 Stack End - Studio
22:25:24.236 nil - Client - Ignition:45
22:25:24.237 Players.lenovo17101.PlayerGui.A-Chassis Interface.Ignition.Ignition:46: attempt to index nil with 'DriveSeat' - Client - Ignition:46
22:25:24.237 Stack Begin - Studio
22:25:24.237 Script 'Players.lenovo17101.PlayerGui.A-Chassis Interface.Ignition.Ignition', Line 46 - function update - Studio - Ignition:46
22:25:24.237 Stack End - Studio
22:25:25.471 nil - Client - Ignition:42
22:25:25.471 Players.lenovo17101.PlayerGui.A-Chassis Interface.Ignition.Ignition:43: attempt to index nil with 'DriveSeat' - Client - Ignition:43
22:25:25.472 Stack Begin - Studio
22:25:25.472 Script 'Players.lenovo17101.PlayerGui.A-Chassis Interface.Ignition.Ignition', Line 43 - function update - Studio - Ignition:43
22:25:25.472 Stack End - Studio
The script that changes the value on the server side:
script.IgnitionChange.OnServerEvent:Connect(function(text)
print("e")
if text == "Off" then
script.IgnitionValue.Value = false
elseif text == "On" then
script.IgnitionValue.Value = true
end
end)
If anything else is needed please ask!