So i'm using a proximity prompt to make a player sit in a vehicle seat.
This is the Sit script
local proximityPromt = script.Parent
local seat = proximityPromt.Parent
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if seat.Occupant then
proximityPromt.Enabled = false
else
proximityPromt.Enabled = true
end
end)
proximityPromt.Triggered:Connect(function(player)
seat:Sit(player.Character.Humanoid)
end)
The UnSit script is inside the vehicle seat not the prompt.
local Players = game:GetService("Players")
local userInputService = game:GetService("UserInputService")
userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.G then
Players.Character.Humanoid.Sit = false
end
end
end)
It supposed to make the humanoid not sit anymore after you press G. But it doesn't work and there is nothing in the output window. I tried using a local script, tried adding the code to the sit script it just doesn't work, Nothing happens when i press the keycode.

1 comment
UserInputService only works on the client and local scripts don't run in the workspace. Change the script to a local script and move the local script somewhere other than workspace. You can see all the different places where local scripts can run here: https://developer.roblox.com/en-us/api-reference/class/LocalScript