I'm not really what to use for this. The BodyPosition is what keeps it in place, 5 studs ahead.
wait() local player=game.Players.LocalPlayer local rs=game:GetService("RunService").RenderStepped local p=Instance.new("Part", workspace) print'Part' p.FormFactor=Enum.FormFactor.Custom p.BrickColor=BrickColor.new("Crimson") p.Size=Vector3.new(1.5,1.5,1.5) p.Material=Enum.Material.Neon p.Transparency=.2 p.CanCollide=false -- local sb=Instance.new("SelectionBox", p) print'Selection Box' sb.Adornee=p sb.Color3=Color3.new(140,0,0) sb.LineThickness=0.02 -- local bp=Instance.new("BodyPosition", p) print'Body Position' spawn(function()while true do bp.Position=player.Character.Torso.Position+Vector3.new(0,0,-5) rs:wait() end end)
There's a more comfortable answer for this
So, take your code. You see the line that says
bp.Position=player.Character.Torso.Position+Vector3.new(0,0,-5)
Now let's change it around a little so it gets the position of the CFrame of the torso.
wait() local player=game.Players.LocalPlayer local rs=game:GetService("RunService").RenderStepped local p=Instance.new("Part", workspace) print'Part' p.FormFactor=Enum.FormFactor.Custom p.BrickColor=BrickColor.new("Crimson") p.Size=Vector3.new(1.5,1.5,1.5) p.Material=Enum.Material.Neon p.Transparency=.2 p.CanCollide=false -- local sb=Instance.new("SelectionBox", p) print'Selection Box' sb.Adornee=p sb.Color3=Color3.new(140,0,0) sb.LineThickness=0.02 -- local bp=Instance.new("BodyPosition", p) print'Body Position' spawn(function()while true do bp.Position=(player.Character.Torso.CFrame*CFrame.new(0,0,-5)).p rs:wait() end end)
Hope this helped!
~Chem
Instead on using a loop use a weld to keep the part in front of the player.
local weld = Instance.new("Weld", game.JointsService) w.C1 = PART2.CFrame:toObjectSpace(PART1.CFrame) w.Part0 = PART1 w.Part1 = PART2 PART2.Anchored = false PART1.Anchored = false
so what i did here is i created a new weld between the PART1 and PART2. next i modified the welds properties so that it would effectively keep the 2 in tact and then unacnhored them so that they can be moved. hope this helped
Here's what I did
1. I used a local script and put it in StarterGui
2. I used LocalPlayer.Character to get the character
3. I used a loop to keep the part's position
--// Gets player local person = game.Players.LocalPlayer --// Inserts a new part into player part = Instance.new('Part',person.Character) --// Edits part's properties part.FormFactor = 'Custom' part.Size = Vector3.new(1.5,1.5,1.5) part.BrickColor = BrickColor.new("Crimson") part.FormFactor = Enum.FormFactor.Custom part.Material = Enum.Material.Neon part.Transparency = .2 part.Anchored = true part.CanCollide = false --// Inserts selection box box = Instance.new("SelectionBox",part) box.Adornee = part box.Color3 = Color3.new(140,0,0) box.LineThickness=0.02 --// Makes part follow player while wait() do part.Position = person.Character.Torso.CFrame * Vector3.new(0,0,-5) -- change to see how far you want it from your torso end
I don't know how to make it follow your torso direction, so the rest is up to you