I already tried doing this using body position and cloning the mesh part locally, but there were some issues with cloning the part upon death, and the body position offset the part and since I need to create a lot of these parts I’d rather have a system that I know works and can use on any number of parts. Is there any way to move a mesh part locally without having to clone it and without using body positions? If not is there a way to move the part locally without using body positions and fixing the cloning issue? The cloning issue is that there would be another mesh part everytime the player died so I deleted the clone upon death, but there still is another part sometimes. Here is my code for the whole thing:
local part = game.Workspace.Level1.KillPart4:Clone()
local originalpart = game.Workspace.Level1.KillPart4
part.CanCollide = true
part.Transparency = 0
part.Anchored = false
part.Name = "b"
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 = 35
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