How to make it so when a player is sat they can't jump

I wish to make it so when players sit in a certain seat, they can’t jump out of the seat.

What’s happening at the moment with

My code
Seat.Touched:Connect(function() 
    local Humanoid = Seat.Occupant 
		game.Players.LocalPlayer.Character.Humanoid.JumpPower = 0
	end)

Is that the character still can jump out of the seat.

Help fixing the code so it works will be appreciated. :slight_smile:


I’ve fixed it, it works now. Thank you for helping everyone!

1 Like

you can just do this

Seat.Touched:Connect(function() 
    local Humanoid = Seat.Occupant 
		game.Players.LocalPlayer.Character.Humanoid.Jumped = false
	end)

With this, the player can still jump out of the seat once sat in it.

do it on a while loop or do a repeat until condition

Even with it looped, it still doesn’t work.

try anchoring their Humanoid Root Part

I tried this earlier, but this caused more issues as it positions the root part with no Z orientation, which messes up the train that I’m making at causes it to glitch all over the place.

Seat.Touched:Connect(function() 
    local Humanoid = Seat.Occupant 
	Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
end)

see more about this

No, this doesn’t work either. The player can still jump out of the seat.

oops

try this code

Seat.Touched:Connect(function() 
    local plr = Seat.Occupant 
	plr.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
end)

Still doesn’t work. I’ll try editing it to get it to work.

let me just fix it for you

Seat.Touched:Connect(function() 
    local plr = Seat.Occupant 
	plr.Character.Humanoid.JumpPower = 0
    print(plr.Character.Humanoid.JumpPower)
end)

No this doesn’t work. :frowning:

You can require the playerModule [Roblox made] and disable their movement via getting their controls. The code would look like this:

Usage Example
-- Local Script --
local PlayerModule = require(LocalPlr.PlayerScripts:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()

-- Player cant move  --
Controls:Disable()

-- Player can move --
Controls:Enable()

Disabling their controls will make it where they can’t jump, and once you want them to be able to walk/jump again just enable their controls.

Code you should be able to use
local localPlr = game:GetService("Players").LocalPlayer
    local PlayerModule = require(localPlr.PlayerScripts:WaitForChild("PlayerModule"))
    local Controls = PlayerModule:GetControls()
local hum = localPlr.Character:WaitForChild("Humanoid")

Seat.Touched:Connect(function() 
    local Humanoid = Seat.Occupant 
    if Humanoid == hum then
        Controls:Disable()
    end
end)

Keep in mind that you can only use this control enable/disable locally so if you aren’t doing this through a local script (which your code example suggests you do with players.LocalPlayer) make sure to handle it through remote events.

You can also alternatively disable the Jump action by unbinding it from ContextActionService while the player is in the seat.

Hope this helps!

1 Like

Hello, thank you for the contribution, but during my testing I was still able to jump up from the seat. I used a local script inside the seat part.

use a server script then paste your code there

But it needs to only apply certain seats, not every seat in the world.

can you please try this code

Seat.Touched:Connect(function() 
    local plr = Seat.Occupant 
	if plr.Character.Humanoid.JumpPower ~= 0 then
        plr.Character.Humanoid.JumpPower = 0
   end
end)

I wouldn’t put the code within the seat. I just tested this by putting a local script in the “StarterPlayerScripts” and got it to work just fine.

LocalScriptInPlayerthing

wow if that was the issue then oof