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 117
6 months 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 330 — 6mo
0
I tried both Xrp200 117 — 6mo

1 answer

Log in to vote
1
Answered by
ScuffedAI 441 Moderation Voter
6 months ago
Edited 6 months 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 117 — 6mo
Ad

Answer this question