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

01local Player = game.Players.LocalPlayer
02Mouse = Player:GetMouse()
03local canJump = true
04local facing = Player.Character.Torso
05 
06Mouse.KeyDown:connect(function(Key)
07    if(Key:lower() == "f") and canJump == true then
08        canJump = false
09        Player.Character.Torso.Velocity = Vector3.new(0,115,200) --How high Player jumps
10        wait(3)
11        canJump = true
12    end
13end)

2 answers

Log in to vote
0
Answered by 7 years ago
01local speed = 100
02 
03local root = Player.Character:WaitForChild("HumanoidRootPart") --R15 does not have a torso
04local thrust = Instance.new("BodyVelocity",root)
05thrust.MaxForce = Vector3.new(100000,100000,100000)
06 
07local target = (root.CFrame * CFrame.new(0,0,-200)) + Vector3.new(0,115,0)
08thrust.Velocity = (target.p - root.CFrame.p).unit * speed
09wait(2)
10thrust:Destroy()

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

1local human = Player.Character:WaitForChild("Humanoid")
2human.WalkSpeed = 30
3human.JumpPower = 80
4human.Jump = true
5wait(1)
6human.WalkSpeed = 16
7human.JumpPower = 50
0
Problem is that it just flings me FAR away from the map Galicate 106 — 7y
Ad
Log in to vote
0
Answered by
Tomstah 401 Moderation Voter
7 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