Hello! i’m having trouble with making the player jump in a direction that they were facing without being able to change direction mid-jump. just like it worked in 2007
See how i only change direction when i land? i want to achieve that but i have no idea where to even begin with this. Help is appreciated!
I utilized HumanoidStateChange to identify the player’s jumping, landing, and free falling actions.
To prevent the Humanoid from changing direction, you can disable Auto Rotate.
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Humanoid = character:WaitForChild("Humanoid")
Humanoid.StateChanged:Connect(function(oldState, newState)
if Enum.HumanoidStateType.Landed == newState then
Humanoid.AutoRotate = true
elseif Enum.HumanoidStateType.Freefall == newState then
Humanoid.AutoRotate = false
elseif Enum.HumanoidStateType.Jumping == newState then
Humanoid.AutoRotate = false
end
end)
the script worked! there is just a thing that i want to also do with this but i don’t know how to. i want the player to not be able to go left or right when jumping, so as shown in the video the player jumps in one direction even though i was pressing W and D keys. Hope i somehow explained it if not then please let me know! (and sorry if i’m asking for too much.)
i have found how to do this myself, what you basically have to do is get the velocity of the humanoid in a variable when they jump and set the current velocity to the variable one and repeat that until the character touches the ground
Should you save the velocity variable as soon as jump is triggered? Or after task.wait(.25). I haven’t tested but it seems like the velocity would be little to none if you save the variable as soon as jump is triggered. Maybe not because of potential energy. But I don’t know if Roblox follows potential energy with velocity.