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

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

Asked by
Nep_Ryker 131
4 years 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 362 — 4y
0
I tried both Nep_Ryker 131 — 4y

1 answer

Log in to vote
1
Answered by
ScuffedAI 435 Moderation Voter
4 years ago
Edited 4 years 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! Nep_Ryker 131 — 4y
Ad

Answer this question