Does adding body positions to a part change the position of the part?

I made a clone of a part using a local script and added body positions to the clone and set its position to the position of the original part, however when I run it, the clone is offset from the original part, I tried disabling the body position to see if that was the issue, and the clone was in the correct position. Does this mean the body position changed the position of the clone, and how do I fix this? Here is my code:

local part = game.Workspace.Level1.KillPart4:Clone()
part.Parent = workspace
part.Name = "b"
local originalpart = game.Workspace.Level1.KillPart4
part.Position = originalpart.Position
local Physics = game:GetService("PhysicsService")
Physics:SetPartCollisionGroup(part, "ClientParts")
local player = game.Players.LocalPlayer     
local char = player.Character
local hum = char:WaitForChild("Humanoid")
local distance = 40
local pos = originalpart.Position
part.CanCollide = true
part.Transparency = 0
part.Anchored = false 

local bp = Instance.new("BodyPosition" ) 
local br = Instance.new("BodyGyro" )
bp.Parent = part
br.Parent = part 
bp.Position = part.Position 
br.MaxTorque = Vector3.new(10000000000000,1000000000000,10000000000000)
bp.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bp.P = 8000
bp.D = 1300  
while true do 
	for i = 0, distance do
		bp.Position = bp.Position + Vector3.new(1,0,0) wait()  
	end 
	for i = 0, distance do
		bp.Position = bp.Position + Vector3.new(-1,0,0)    wait() 
	end 

	hum.Died:Connect(function() 
		originalpart.Parent = workspace.Level1
		originalpart.Position = pos
		wait() 
		part:Destroy()	
	end)

end  

I also have another issue where when the player dies there are now 2 clones, I tried to fix this by making it so that the clone would get deleted upon the player dying, however sometimes the issue is still there, is there anything I’m doing wrong?

Why are you running this twice?

This is creating a loop that varies the bp offset by (1,0,0) then almost instantly tries to make the offset (-1,0,0). I’d guess that this is the issue with your offset problem.

Also you should set all the part's Properties first, then set its Parent to Workspace.

1 Like

Well, what I’m trying to do is make it move to the right for a certain distance, then move back the same distance and continue looping that forever, how would I achieve that without having the offset, meaning how would I move it to the right for a bit then come back to the same distance, so it never leaves that path?

Also here is what the offset looks like
image
The part to the left is the original part that I’m cloning, and the part to the right is where the path of the clone starts, I want the clone to start from where the original part is.

Why don’t you Anchor it and use TweenService | Roblox Creator Documentation?

I need the parts to be able to move the player if they stand on it so I need to use body position to move them.

Also, I tried parenting the part after setting all the properties but sometimes there is still an extra part upon death, here is my new code

local part = game.Workspace.Level1.Part1:Clone()
local originalpart = game.Workspace.Level1.Part1
part.CanCollide = true
part.Transparency = 0
part.Anchored = false  
part.Name = "b"
part.Position = originalpart.Position
part.Parent = workspace
local Physics = game:GetService("PhysicsService")
Physics:SetPartCollisionGroup(part, "ClientParts")
local player = game.Players.LocalPlayer     
local char = player.Character
local hum = char:WaitForChild("Humanoid")
local distance = 55
local pos = originalpart.Position
local bp = Instance.new("BodyPosition" ) 
local br = Instance.new("BodyGyro" )
bp.Parent = part
br.Parent = part 
bp.Position = part.Position 
br.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
bp.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bp.P = 8000
bp.D = 1300  
while true do
	wait(1)
	for i = 0, distance do
		bp.Position = bp.Position + Vector3.new(0,0,-1) wait()  
	end
	wait(2)
	for i = 0, distance do
		bp.Position = bp.Position + Vector3.new(0,0,1)    wait() 
	end 

	hum.Died:Connect(function() 
		originalpart.Parent = workspace.Level1
		originalpart.Position = pos
		wait() 
		part:Destroy()	
	end)

end  

Unless u meant to parent it after the creating the body position.