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)```
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
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