Help with a script

So basically, I’ve been having issues with a script I have.

What this script basically does is just don’t allow you to move in the air when jumping. I kinda want this script to just, when you jump it doesn’t allow you to move in the air, but I want it so if you hit something like a wall it just inverts the lastvelocity and bounces you back to place.

I need this script for an April 2007 roblox simulator I’m making (which you can find here) since the client for that era also had that exact feature. I’ve been trying to modify the script I mentioned earlier countless times and failing catastrophically.
Here’s the script I’m talking about.

local humanoid = script.Parent:WaitForChild("Humanoid")
local rootpart = script.Parent:WaitForChild("Torso")
local lastvelocity = Vector3.new(0,0,0)
local locking = false
humanoid.Jumping:Connect(function()
	locking = true
end)
game:GetService("RunService"):BindToRenderStep("jumpLock",Enum.RenderPriority.Character.Value+1,function()
	if humanoid and rootpart then
		if humanoid:GetState() == Enum.HumanoidStateType.Freefall and locking == true then
			humanoid:Move(lastvelocity,false)
			humanoid.AutoRotate = false
		elseif humanoid:GetState() == Enum.HumanoidStateType.Running or humanoid:GetState() == Enum.HumanoidStateType.RunningNoPhysics then
			lastvelocity = rootpart.Velocity/humanoid.WalkSpeed
			humanoid.AutoRotate = true
			locking = false
			lastvelocity = rootpart.Velocity/humanoid.WalkSpeed
			humanoid.AutoRotate = true
			locking = false
		else
			humanoid.AutoRotate = true
		end
	end
end)
local humanoid = script.Parent:WaitForChild("Humanoid")
local rootpart = script.Parent:WaitForChild("Torso")
local lastvelocity = Vector3.new(0,0,0)

game:GetService("RunService"):BindToRenderStep("jumpLock",Enum.RenderPriority.Character.Value+1,function()
	if humanoid and rootpart then
		if humanoid:GetState() == Enum.HumanoidStateType.Running or humanoid:GetState() == Enum.HumanoidStateType.RunningNoPhysics then
			lastvelocity = rootpart.Velocity/humanoid.WalkSpeed
			humanoid.AutoRotate = true
			
			lastvelocity = rootpart.Velocity/humanoid.WalkSpeed
			humanoid.AutoRotate = true

		else
			humanoid.AutoRotate = true
		end
	end
end)

In old script, when player jumps, script disable movement using variable ‘locking’

oops yeah true but still doesn’t help with what i need

Does it output any errors? (Why for answer i need more that 30 symbols :sob:)

no, the script works fine. i just need to modify it in some way to make it do what i specified in the post, but i just can’t find a way to.

found the issue… thanks anwyays

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.