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 find the orientation of a players torso?

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)

1 comment

2 answers

✓ Accepted answer
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

1 comment

0

Problem is that it just flings me FAR away from the map

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.)

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