Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make the players HumanoidRootPart move to the right?

local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Cooldown = false
local Cdtime = 4

UserInputService.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.Q then 
	if Cooldown then return end 

	
	spawn(function()
		Cooldown = true
		wait(Cdtime)
		Cooldown = false 
	end)

local Root = Player.Character:WaitForChild("HumanoidRootPart")
Root.Velocity = Root.Velocity + Vector3.new(80,0,0)
		
	end
end)

I do that but only works if I face the Z-Axis and messes up. So my question is how do I make the player move right a bit because the way I did it is weird and I can't think of any other way. Any help is appreciated thanks a lot

1 comment

0

Have you tried using BodyVelocity?

1 answer

✓ Accepted answer

What you're looking at is starting to get into CFrames. CFrames are basically a mixture of the Position and the Orientation of something. Some of the properties of CFrame are as follows:

CFrame.lookVector
CFrame.rightVector
CFrame.upVector

In order to move the character a certain direction depending on where they're looking, you need to do something like this.

rootPart.Velocity = rootPart.Velocity + rootPart.CFrame.lookVector*100 -- This makes the velocity of the character's Root Part 100 in the direction it's facing, so it would move the character forward.

If you wanted to move the character left, back, or down, you would do something like this:

rootPart.Velocity = rootPart.Velocity + rootPart.CFrame.rightVector*-100 -- You would just make it times a negative number in the opposite direction.

Hope I helped!

This discussion is preserved as it was. New answers, comments, and votes are closed.