Trying to make a sit check

Trying to make a sit check where it only fires the remote once you are sitting on this seat and pressing f, I’m trying to make the restriction after if input.KeyCode == Enum.KeyCode.F then but I’m not sure how to do it

local Players = game:GetService("Players")
local player = Players.LocalPlayer.Character.Humanoid
local IsSitting = false
local function onOccupantChanged()
	local humanoid = seat.Occupant
	if player == humanoid then
		IsSitting = true
		

	end
end
local UserInputService = game:GetService("UserInputService")
local remoteEvent = game.ReplicatedStorage.ShootSmoke
UserInputService.InputBegan:Connect(function(input)

	if input.KeyCode == Enum.KeyCode.F then
		if 
		remoteEvent:FireServer()
		print("hi")
	end    
end)```

Sitting on a particular seat or sitting on any seat?

Cause if its for the ladder there is a function inside of Humanoid

A particular seat on the cannon

I think you could just do

if humanoid.SeatPart and humanoid.SeatPart == SEAT_PART_PATH then
     -- fire remote event
end

Let me test it out rq ill tell you if it works

1 Like

I think it would be better to use ```local UserInputService = game:GetService(“UserInputService”)
local remoteEvent = game.ReplicatedStorage.ShootSmoke
UserInputService.InputBegan:Connect(function(input)

if input.KeyCode == Enum.KeyCode.F then
	if humanoid.seat == seat then
		if IsSitting == true then
			remoteEvent:FireServer()
		print("hi")
		end
	
	end 
end	

end)```

1 Like

Did it end up working for you though?

I’m getting a weird error "ArtillerySeat is not a valid member of Model “Workspace.ScriptedArtillery” yet it is in this scriptlocal seat = game.workspace.ScriptedArtillery.ArtillerySeat local Players = game:GetService("Players") local player = Players.LocalPlayer.Character.Humanoid local IsSitting = false local function onOccupantChanged() local humanoid = seat.Occupant if player == humanoid then IsSitting = true end end
image|287x43

image

Maybe try doing a WaitForChild for the ArtillerySeat