How to lock the rotate for player while rolling

hello im amaro and im trying to make this movement from the game, called,
ultrakill:

and i replicated but something is make it very difficult to achive is that, while doing this movement, the character can rotate and here is a video and is very explanatory:

so i try to search any post from the forum to lock the orientation or something of the humanoidrootpart, even try to use alignorientation for the first time, but couldnt do nothing basicly. and here is the script, tbh i dont know why the alignt orientation is not working, but i could try other method to make the orientation or something from the humanoidrootpart, lock it.:

local uis = game.UserInputService
local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local char = player.Character
local debounce = script.Parent.Debounce
local jump = script.Parent.Jump
local hum = char.Humanoid
local hrp = char.HumanoidRootPart
local anim = Instance.new("Animation", hrp)
anim.AnimationId = "rbxassetid://15921106935"
local animations = {
	roll = hum:LoadAnimation(anim)
}

uis.InputBegan:Connect(function(key, proces)
	if proces == true then return end
	if debounce.Value == true then return end
	if key.KeyCode == Enum.KeyCode.LeftShift then
		local lookvector = hrp.CFrame.LookVector
		local orientation = hrp.CFrame.Rotation
		animations.roll:Play()
		debounce.Value = true
		hum.AutoRotate = false

		local partreference = Instance.new("Part", hrp)
		partreference.Anchored = false
		partreference.CanTouch = false
		partreference.CanCollide = false
		partreference.Size = Vector3.new(1,1,1)
		partreference.Name = "CULO"

		local weld = Instance.new("Motor6D", hrp)
		weld.Part0 = partreference
		weld.Part1 = hrp
		weld.Name = "motor"
		weld.C0 = CFrame.new(0,0,0) * CFrame.Angles(0,0,0)

		local attachmente1 = Instance.new("Attachment", hrp)
		attachmente1.Name = "first"

		local attachmente2 = Instance.new("Attachment", partreference)
		attachmente2.Name = "second"

		local alignorientation = Instance.new("AlignOrientation", hrp)
		alignorientation.Attachment0 = attachmente2
		alignorientation.Attachment1 = attachmente1
		alignorientation.Enabled = true

		local velocity = Instance.new("BodyVelocity", hrp)
		velocity.MaxForce = Vector3.new(math.huge, 0, math.huge)
		velocity.Name = "dick"
		velocity.P = 10000
		velocity.Velocity = lookvector * 100
	elseif key.KeyCode == Enum.KeyCode.Space then
		jump.Value = true
	end
end)

uis.InputEnded:Connect(function(key, proces)
	if proces == true then return end
	if key.KeyCode == Enum.KeyCode.LeftShift then
		animations.roll:Stop()
		debounce.Value = false
		char.Humanoid.AutoRotate = true
		local humnaoid = char.HumanoidRootPart
		local array = humnaoid:GetChildren()

		local Part1 = humnaoid.dick
		local Part2 = humnaoid.CULO
		local Part3 = humnaoid.motor
		local Part4 = humnaoid.first
		local Part5 = Part2.second

		if table.find(array, Part1) or table.find(array, Part2) or table.find(array, Part3) or table.find(array, Part4) or table.find(array, Part5) then
			game.Debris:AddItem(Part1, 0)
			game.Debris:AddItem(Part2, 0)
			game.Debris:AddItem(Part3, 0)
			game.Debris:AddItem(Part4, 0)
			game.Debris:AddItem(Part5, 0)

		end
	elseif key.KeyCode == Enum.KeyCode.Space then
		jump.Value = false
	end
end)

(client side script btw)

2 Likes

the name of the velocity is crazy :fire:
image
anyways, I don’t have a solution to the problem, but I have a slide of my own that moves the player while giving them walkspeed corresponding on how fast I want them to go. It’s much more easy to handle than using velocity.
https://gyazo.com/81af0119674c31f66d593330bc32a438

3 Likes

sorry for the names, im very lazy sometimes to writte a name for anything, so i type random things

3 Likes

and i mean, idk i can i have ittt??? idk just to check it out

3 Likes
 game.UserInputService.InputBegan:Connect(function(input)
	if plr.Weapon.Value ~= "Ultrakill" then return end
	if input.KeyCode == Enum.KeyCode.LeftControl then
		if hum.FloorMaterial == Enum.Material.Air then return end
		game.ReplicatedStorage.BoolVal:FireServer(plr.Sliding,true)
		slide:Play()
		game.ReplicatedStorage.Sounds.Slide:Play()
		CanSlam = false
		CanDash = false
		hum.JumpPower = 0
		hum.CameraOffset = Vector3.new(0,-2,0)
		local autorun = game:GetService("RunService").RenderStepped:Connect(function(dt)
			hum:Move(Vector3.new(0,0,-1), true) --Moving the player
		end)
		local run = true

		spawn(function()
			while run do
				task.wait(0.1)
				hum.WalkSpeed -= 1 --Lowering the speed of the slide (friction)
				if hum.WalkSpeed == 1 then
					game.ReplicatedStorage.Sounds.Slide:Stop()
				end
			end
		end)
		hum.WalkSpeed += 7 * multiplier


		game.UserInputService.InputEnded:Connect(function(input)
			if input.KeyCode == Enum.KeyCode.LeftControl then
				autorun:Disconnect()
				game.ReplicatedStorage.Sounds.Slide:Stop()
				slide:Stop()
				hum.JumpPower = 60
				run = false
				hum.CameraOffset = Vector3.new(0,0,0)
				CanSlam = true
				CanDash = true
				game.ReplicatedStorage.BoolVal:FireServer(plr.Sliding,false)
				delay(0.4,function()
					if hum.FloorMaterial == Enum.Material.Air then
						if hum.WalkSpeed < 20 then
							hum.WalkSpeed = 20
						end
					else
						hum.WalkSpeed = 20
					end
				end)
			end
		end)
	end
end)

theres a whole bunch of other stuff catered to my own game so just remove that :yawning_face:

2 Likes

Try updating the velocity every frame so it captures the new LookVector.

Code:

local uis = game.UserInputService
local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local char = player.Character
local debounce = script.Parent.Debounce
local jump = script.Parent.Jump
local hum = char.Humanoid
local hrp = char.HumanoidRootPart
local anim = Instance.new("Animation", hrp)
anim.AnimationId = "rbxassetid://15921106935"
local animations = {
	roll = hum:LoadAnimation(anim)
}

uis.InputBegan:Connect(function(key, proces)
	if proces == true then return end
	if debounce.Value == true then return end
	if key.KeyCode == Enum.KeyCode.LeftShift then
		local lookvector = hrp.CFrame.LookVector
		local orientation = hrp.CFrame.Rotation
		animations.roll:Play()
		debounce.Value = true
		hum.AutoRotate = false

		local partreference = Instance.new("Part", hrp)
		partreference.Anchored = false
		partreference.CanTouch = false
		partreference.CanCollide = false
		partreference.Size = Vector3.new(1,1,1)
		partreference.Name = "CULO"

		local weld = Instance.new("Motor6D", hrp)
		weld.Part0 = partreference
		weld.Part1 = hrp
		weld.Name = "motor"
		weld.C0 = CFrame.new(0,0,0) * CFrame.Angles(0,0,0)

		local velocity = Instance.new("BodyVelocity")
		velocity.MaxForce = Vector3.new(math.huge, 0, math.huge)
		velocity.Name = "dick"
		velocity.P = 10000
		velocity.Parent = hrp
		
		while task.wait() and velocity:IsDescendantOf(workspace) do
			lookvector = hrp.CFrame.LookVector
			velocity.Velocity = lookvector * 100
		end
	elseif key.KeyCode == Enum.KeyCode.Space then
		jump.Value = true
	end
end)

uis.InputEnded:Connect(function(key, proces)
	if proces == true then return end
	if key.KeyCode == Enum.KeyCode.LeftShift then
		animations.roll:Stop()
		debounce.Value = false
		char.Humanoid.AutoRotate = true
		local humnaoid = char.HumanoidRootPart
		local array = humnaoid:GetChildren()

		local Part1 = humnaoid.dick
		local Part2 = humnaoid.CULO
		local Part3 = humnaoid.motor

		if table.find(array, Part1) or table.find(array, Part2) or table.find(array, Part3) or table.find(array, Part4) or table.find(array, Part5) then
			game.Debris:AddItem(Part1, 0)
			game.Debris:AddItem(Part2, 0)
			game.Debris:AddItem(Part3, 0)
		end
	elseif key.KeyCode == Enum.KeyCode.Space then
		jump.Value = false
	end
end)
3 Likes

A little late but, while in the roll, set Humanoid.AutoRotate to false and set it to true when the roll ends