Basically what I am trying to do Is now that I have gotten rid of HumanoidController and I decided to start my own HumanoidController" but I do not know if it is possible to use Cframe when key == 'w' so that once the player does this it will move you forward in the camera direction using Cframe. I think this is possible but I do not know for sure. :/
Hope there is some explanation to this.
001 | repeat wait( 1 / 60 ) until game.Players.LocalPlayer.Character and |
002 | game.Workspace.CurrentCamera |
003 | repeat wait( 1 / 60 ) until game.Players.LocalPlayer.Character:FindFirstChild( "Torso" ) |
004 |
005 | local Camera = game.Workspace.CurrentCamera |
006 | local Torso = game.Players.LocalPlayer.Character.Torso |
007 | Camera.CameraType = "Scriptable" |
008 | Camera.CameraSubject = nil |
009 |
010 | repeat wait() until game.Players.LocalPlayer:FindFirstChild( "PlayerGui" ) |
011 |
012 | local Player = game.Players.LocalPlayer |
013 | local size = Instance.new( "ScreenGui" , Player.PlayerGui) |
014 | size.Name = "Size" |
015 |
You need to CFrame the Character's Torso relatively to itself, but with an offset of however much you want to move them multiplied by the lookVector
of the Camera's CoordinateFrame.
Expected to be in a LocalScript
01 | wait( 1 ) |
02 |
03 | local cam = workspace.CurrentCamera |
04 | local plr = game.Players.LocalPlayer |
05 | local tor = plr.Character:WaitForChild( 'Torso' ) |
06 |
07 | --Relatively to itself |
08 | tor.CFrame = tor.CFrame |
09 | --How much you want to move them |
10 | * CFrame.new((CFrame.new( 0 , 0 ,- 1 ) |
11 | --Multiplied by lookVector of the Camera's CoordinateFrame |
12 | * cam.CoordinateFrame.lookVector * 1 )) |
You can always use the Move
method of Humanoid.
Move (Vector3 moveDirection, bool relativeToCamera)
The first argument is just the the Vector3, or 3D point in the place, or position you want your *humanoid *(player) to head towards until interrupted by the pressing of keys or a certain object
The second argument is set to false
by default
setting it to true
would mean allowing the movement
of the player to in relation or proportion to the Camera
1 | local player = game.Players.LocalPlayer |
2 | local character = player.Character or player.CharacterAdded:wait() |
3 | local humanoid = character:WaitForChild( 'Humanoid' ) |
4 |
5 | humanoid:Move(Vector 3. new( 45 , 0 , 45 ), true ) |
Well,Im getting it that you want the player to move into the direction the camera is focusing on.
Well,A decent explenation is,Just make the camera move/focus on whatever brick you want,And then make another part that you want the player to walk to and use the :MoveTo() on the player's humanoid (MoveTo() to the position of the part you want the player to walk into),But be sure to disable the player's control or just while true do it and then break the code once the player is there.