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?