Log in to vote

How can I make a part I spawn on my player spawn a few studs away instead of directly on it?

Asked by 15 days ago

Hey everyone, I am yet again asking for your assistance.

Here is the script:

local tool = script.Parent
local player = game.Players.LocalPlayer


    local part = game.Workspace:FindFirstChild("BariWall")
    local ClonedPart = part:Clone()
    part.Parent = workspace
    part.Position = player.Character:WaitForChild("UpperTorso").Position 


What this script does:

In this script, every time the tool is activated, it spawns a wall directly on the side of the UpperTorso. I am wondering if it is posible to change the position(Last line), to something that spawns it in the position + 5 studs(or so) 

Any help is appreciated

Use the HRP's CFrame as it will respect the current orientation and direction of your character. As for offsetting the placement, multiply the HRP's CFrame by another with your desired padding. Ziffixture 6863 — 15d
If you do not want your part's orientation to align with the character's, set its Position to the HRP's LookVector and offset it by adding another vector with your desired padding. Ziffixture 6863 — 15d
If you want to disrespect both orientation and direction, simply perform the last step of #2 on your current code. Ziffixture 6863 — 14d

Answer this question