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

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

Asked by 2 years ago

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

Here is the script:

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

tool.Activated:Connect(function()

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

end)

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

1
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 6913 — 2y
1
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 6913 — 2y
1
If you want to disrespect both orientation and direction, simply perform the last step of #2 on your current code. Ziffixture 6913 — 2y

Answer this question