How can I make an existing mesh part with an id local and move it locally using body positions?

To make the mesh part local what I’m doing is cloning it in a local script,(I’m not sure if this is the correct way to do it) and adding body positions to the clone. When I run the code in studio it works fine, but if I start a local server the mesh either isn’t there at all or is in the wrong position. how would I go about fixing this issue, also here is my code:

image

Also the script is inside starter gui, I’m not sure if that is wats wrong.

Do you mind sending the code so I can test it myself?

local part = game.Workspace.sand:Clone()
local originalpart = game.Workspace.sand 
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 = 45 
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(0,1,0) wait()  
	end
	for i = 0, distance do
		bp.Position = bp.Position + Vector3.new(0,-1,0)    wait() 
	end  
	hum.Died:Connect(function()
		part:Destroy()
		originalpart.Parent = workspace
		originalpart.Position = Vector3.new(4.379, 29.1, -543.411)
	end)
end   
1 Like

I think the issue has to do with the cloning.

I dont see the part where you parent the clone?? (This means the parts parent is nil, so you should set it to like workspace or smthg)

Are u talking about the part that is the clone?

Thanks that fixed the issue but can u tell me what parenting the clone does? Previously I didn’t have it parented, yet the part was still visible for me just in a different position than what I specified, why does parenting it to the workspace fix this issue?

I think you just saw something else (not the clone)

But I have no other parts like that and the original was transparent so I’m sure that was it.