I’m working on my own submarine, and I’ve reached a complication. I’m having trouble preventing the player from jumping from their seat. Like any other seat, you sit on it, and press the Spacebar to jump. I’d like to move the dismount key to Backspace as opposed to the Spacebar, so that the Spacebar can be used to raise the submarine.
I’ve attempted to set the JumpPower to 0, I’ve tried making my own additional weldconstraint between the humanoidrootpart and the seat, and I’ve tried disabling the Jumping state with SetStateEnabled. None of these have worked.
I am unsure if PlayerModule:GetControls():Disable() will disable jumping out of a seat or not, worth a try… it may also disable vehicle seat input, though.
You could try utilizing ContextActionService to temporarily override the spacebar input to jump, and then re-bind jumping to backspace. Check out the functions here.
You may use ContextActionService to temporarily unbind the Jump event.
local ContextActionService = game:GetService('ContextActionService')
ContextActionService:UnbindAction("jumpAction")
Alternatively you can use this approach with UserInputService.
-- Services
local userInputService = game:GetService("UserInputService")
local players = game:GetService("Players")
-- Local player
local player = players.LocalPlayer
local character = player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
-- Fires when the user tries to jump
local function Jump()
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
end
userInputService.JumpRequest:Connect(Jump)
This question has been asked several times over. Please search the DevForum first before asking. This is a post from some time ago where I explain how you can stop player jumping.
For quick reference without opening the post, these are the methods I proposed:
Setting JumpPower to 0
Forcing the Humanoid’s Jump property to false
Forcing the Humanoid’s Jump state not to enable (or disabling it)
Update: I’ve found that it only works when the seat is anchored. It does not work if the seat is unanchored, and welded to the submarine. I’ve tried both a WeldConstraint, and by changing the BottomSurface of the seat to Glue and Weld.
Unfortunately, the submarine cannot move without be unanchored altogether.
local jumpDisabled = false
ContextActionService:BindActionAtPriority("JumpOverride", function()
if jumpDisabled then
return Enum.ContextActionResult.Sink
else
return Enum.ContextActionResult.Pass
end
end, false, Enum.ContextActionPriority.High, Enum.PlayerActions.CharacterJump, Enum.KeyCode.Space)
Then you can just set jumpDisabled to true or false.
EDIT: Corrected to Enum.PlayerActions.CharacterJump
This is extra nice because you can then hook in your submarine control right there where it returns Sink.