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

How do you create an object in front of a player?

Asked by
mruno 20
10 years ago

So far I create the object to a certain side of the player, no matter which direction he is facing.

shield.Position=spawnPos+Vector3.new(0,0,5)

How do you make it so it spawns directly in front of you no matter where you're facing?

1 answer

Log in to vote
2
Answered by 10 years ago

It's as simple as this:

shield.CFrame = spawnCFrame * CFrame.new(0, 0, 5):inverse()

So, when positioning, you should use CFrame instead, otherwise the part would get placed above parts that are in the way.

Also, as variable spawnCFrame suggests, you should have the CFrame of the origin(torso I guess), not position, like in your original script.

0
Understood, thanks for clearing that up :) mruno 20 — 10y
Ad

Answer this question