Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I find the orientation of a players torso?

Asked by
Galicate 106
6 years ago

Im making a script where a player can thrust forward in the direction he/she is facing. The only problem is that i can't find the direction the player is facing.

local Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
local canJump = true
local facing = Player.Character.Torso

Mouse.KeyDown:connect(function(Key)
    if(Key:lower() == "f") and canJump == true then
        canJump = false
        Player.Character.Torso.Velocity = Vector3.new(0,115,200) --How high Player jumps
        wait(3)
        canJump = true
    end
end)

2 answers

Log in to vote
0
Answered by 6 years ago
local speed = 100

local root = Player.Character:WaitForChild("HumanoidRootPart") --R15 does not have a torso
local thrust = Instance.new("BodyVelocity",root)
thrust.MaxForce = Vector3.new(100000,100000,100000)

local target = (root.CFrame * CFrame.new(0,0,-200)) + Vector3.new(0,115,0)
thrust.Velocity = (target.p - root.CFrame.p).unit * speed
wait(2)
thrust:Destroy()

If you want another approach where they can move freely then do this

local human = Player.Character:WaitForChild("Humanoid")
human.WalkSpeed = 30
human.JumpPower = 80
human.Jump = true
wait(1)
human.WalkSpeed = 16
human.JumpPower = 50
0
Problem is that it just flings me FAR away from the map Galicate 106 — 6y
Ad
Log in to vote
0
Answered by
Tomstah 401 Moderation Voter
6 years ago

If the above solution works, but is too powerful, I'mma add onto it. Excuse me if I'm supposed to comment instead, but it is a solution.

Instead of using the Velocity property which is known for it's wild sporadic behavior, use BodyThrust. It's built into ROBLOX. It's very similar to any of the other BodyMover classes (Because it is one.)

Answer this question