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

Is there a Player Direction function?

Asked by 8 years ago

Hello. I am trying to create a piece of code that spawns a part in front of the player, but the direction the player is facing will cause the part to spawn at the back of the player at times. What I want to know is if there is a function or event that will execute a block of code depending on the direction a player is facing. Thank you.

1 answer

Log in to vote
2
Answered by 8 years ago

You just use the players Torso CFrame then just add an offset to it.

Simple Example:-

local a = Instance.new('Part', game.Workspace) 
-- we use the players Torso CFrame
a.CFrame = game.Workspace.Player1.Torso.CFrame *  CFrame.new(0,0,-2) -- this is the offset

I hope this helps.

0
Wow! This works like a charm. DepressionSensei 315 — 8y
Ad

Answer this question