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:
Also the script is inside starter gui, I’m not sure if that is wats wrong.
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
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?