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.
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.