UserInputService vehicle seat help

I am trying to make it so when a player sits in an vehicle seat it and presses K it fires the event
I have tried to use chatgpt but it didn’t help.
If somebody sees an flaw please say!
I also don’t see any error in the console or output.
I created an backup script that prints something when it is pressed it printed out an line but it doesn’t print anything.

Schermafbeelding 2024-01-13 204326

local seat = script.Parent.VehicleSeat
local UIP = game:GetService("UserInputService")
local gKeyEvent = script.Parent:WaitForChild("SmokeEvent")

local function onInputBegan(input, gameProcessedEvent)
	if not gameProcessedEvent then
		if input.KeyCode == Enum.KeyCode.K then
			local occupant = seat.Occupant
			if occupant and occupant:IsA("Player") then
				gKeyEvent:FireServer()
			end
		end
	end
end

UIP.InputBegan:Connect(onInputBegan)

Fixed myself, forgot that local scripts with UIP need to be in the player it self to work.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.