I am trying to spawn a part 6 studs in front of the character, no matter how it’s rotated.
Here is my current code:
local Model = workspace.Rig
local Part = Instance.new("Part")
Part.Size = Vector3.new(0,0,0)
Part.Parent = workspace
Part.Position = Model.HumanoidRootPart.Position + Vector3.new(0,0,-6)
At the moment the part isn’t always spawning in front of the player. I’m not that experienced with vector and cframe. but does anyone have a fix for this?
local function FindPosition(RootPart, OffsetStuds)
-- Add the multiplied direction to the current position
return RootPart.Position + RootPart.CFrame.LookVector * OffsetStuds
end
local p = Instance.new("Part",workspace)
p.Position = (game.Players[SomePlayer].Character.HumanoidRootPart*CFrame.new(0,0,-6)).p
-- or
-- p.CFrame= game.Players[SomePlayer].Character.HumanoidRootPart*CFrame.new(0,0,-6)