New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How to make a model spawn directly in front of a player?

Asked by
Xrp200 115
10 days ago

So I'm trying to make it that if you press E, there will be a model that should spawn in front of you. I've made it spawn at the player, but I don't know how to make it spawn in front of the player.

I used SetPrimaryPartCFrame to move the model. If I increase the X or Z value it won't work as I want it to because it would only work if I look at a specific direction. So I'm looking for if there's a way I can make it spawn in front of the player regardless which direction they're looking at? Any help is appreciated!

0
Were you using the player's position or CFrame when setting the model's CFrame? XxTrueDemonxX 325 — 10d
0
I tried both Xrp200 115 — 10d

1 answer

Log in to vote
1
Answered by
Kate_Ai 113
10 days ago
Edited 10 days ago

-- We use the HumanoidRootPart which is a -- part that's located inside of the player character -- Be sure to set this values yourself local HumanoidRootPart; local YourModel; -- This will return a cframe that's infront of the player by 5 studs local offset = CFrame.new(0,0,-5) local InfrontOfPlayer = HumanoidRootPart.CFrame * offset YourModel:SetPrimaryPartCFrame(InfrontOfPlayer)
0
Thank you! Xrp200 115 — 10d
Ad

Answer this question