How would i clone a part in front of an object?

hey, so I was just practicing my scripting and I decided to try this: when a player steps on a brick, a block will spawn in the front position. (I could’ve just used vector3 value but im planning to try move this onto a player)

heres a script I tried: (yes, the touched events and variables are already there)

part:Clone().Position = part.FrontSurface + Vector3.new(0,0,10)

but an error pops up: [Workspace.Part.Script:9: bad argument #1 (Vector3 expected, got EnumItem)]

what did I do wrong? line 9 is the line I just provided.

local p = part:Clone()
local SomeOtherPart = --//path to another part

p.CFrame = SomeOtherPart.CFrame * CFrame.new(1, 0, 0)
p.Parent = workspace

Something like that should be what you’re looking for.

2 Likes

C sharper is 100% correct. If you can’t copy and paste. I have a video on my YouTube. It explains how to clone a part in front of the most recent touch part. Also how to make a part visible when touching a part.

You should probably use CFrame.LookVector:

part:Clone().CFrame = part.CFrame + part.CFrame.LookVector * distance

This will put the clone in front of the part, no matter what direction it is currently facing. (replace the distance with any number you want)