I am trying to make a LocalScript which modifies the player’s ability to jump top be similar to Old Roblox, not being able to change direction when you jump. You probably already know the issue, but the issue is that when I am moving in a straight line and I jump, I suddenly stop moving.
local Humanoid = script.Parent:WaitForChild("Humanoid")
local Player = game:GetService("Players").LocalPlayer
local PlayerScripts = Player.PlayerScripts
local PlayerModule = require(PlayerScripts:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()
Humanoid.StateChanged:Connect(function(old,new)
if new == Enum.HumanoidStateType.Jumping then
Humanoid.AutoRotate = false
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping,false)
Controls:Disable()
elseif new == Enum.HumanoidStateType.Landed then
Humanoid.AutoRotate = true
Controls:Enable()
task.wait(1)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping,true)
end
end)
when you disable the controls, you stop it from detecting your move direction. since it says your movedirection is Vector3.new(0, 0, 0), it no longer moves you forward. you’d have to log their current X and Z velocity as soon as they jump and use either a BodyVelocity or LinearVelocity to continue handling their velocity.
Alternatively, you can fork over the ControlModule and if your Humanoid.FloorMaterial is Air then stop it from updating your move direction so it constantly keeps the last known movement direction.
The issue you’re facing is likely due to the line Controls:Disable() which is disabling player input while jumping. This is causing the character to stop moving when you jump.
So to fix this, you don’t need to disable player input. you can fix this by modifying the character’s physics instead.
you can use Humanoid:Move(Vector3.new(0, 0, 0) to disable character’s root motion
then just you disable/enable char rotation.
local Humanoid = script.Parent:WaitForChild("Humanoid")
local Player = game:GetService("Players").LocalPlayer
Humanoid.StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.Jumping then
Humanoid:Move(Vector3.new(0, 0, 0), false)
Humanoid.AutoRotate = false
elseif new == Enum.HumanoidStateType.Physics then
Humanoid.AutoRotate = true
end
end)
i’m checking out the module, it appears on line 546 theres a function called self.moveFunction. in this function it passed the localplayer, the moveVector it gets from the controls, and a false value. what you could do is fork this over and be like:
if Player.LocalPlayer.Character and Player.LocalPlayer.Character:FindFirstChild'Humanoid' and Player.LocalPlayer.Character.Humanoid.FloorMaterial ~= Enum.Materials.Air then
self.moveFunction(Players.LocalPlayer, moveVector, false)
end
its a scrambled mess but its the general idea
FYI this is in the same module where you call the :Disable() and :Enable() methods
rip, i guess that wasn’t the movement update function. i’d poke around in that script trying to find where it gets inputted, however if you don’t wanna spend that much time on it, it’d be easier to make a bodymover approach
local Humanoid = script.Parent:WaitForChild("Humanoid")
local Player = game:GetService("Players").LocalPlayer
local PlayerScripts = Player.PlayerScripts
local PlayerModule = require(PlayerScripts:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()
local isJumping = false
local function DisablePlayerInput()
Controls:Disable()
end
local function EnablePlayerInput()
Controls:Enable()
end
Humanoid.StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.Jumping then
Humanoid.AutoRotate = false
isJumping = true
DisablePlayerInput()
elseif new == Enum.HumanoidStateType.Freefall then
isJumping = false
DisablePlayerInput()
elseif new == Enum.HumanoidStateType.Seated or new == Enum.HumanoidStateType.Physics then
isJumping = false
DisablePlayerInput()
elseif new == Enum.HumanoidStateType.Climbing or new == Enum.HumanoidStateType.Swimming then
isJumping = false
DisablePlayerInput()
else
if isJumping then
Humanoid.AutoRotate = true
task.wait(0.1)
EnablePlayerInput()
isJumping = false
end
end
end)
The player needs to be able to keep moving while in the air, make sure to add Humanoid:Move() after Controls have been disabled to the character keeps moving.