Hello! So, I’m creating a minimap that marks other players on the map with a part cloned from ReplicatedStorage. The problem I’m having, though, is updating the position of the part in the viewportFrame. I get intense lag each time the update position part is run, but not when updating the camera position or the local player’s icon rotation. Is there a better way to move objects in a ViewPortFrame?
*Edit: Changed some code to resolve a memory leak
local debounce = false
local TS = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
function renderMap()
-- Works Fine
camera.CFrame = CFrame.new(hrp.Position + Vector3.new(0, 10000, 0), hrp.Position)
playerIcon.Rotation = -hrp.Orientation.Y - 90
if not debounce then
debounce = true
-- The Problem Area, works fine if the icon is parented to Workspace, but not the ViewPortFrame
for _, icon in pairs(playerIcons) do
TS:Create(
icon,
tweenInfo,
{Position = game.Players:GetPlayerByUserId(tonumber(icon.Name)).Character:FindFirstChild("HumanoidRootPart").Position}
):Play()
end
task.wait(1)
debounce = false
end
end
RunService.RenderStepped:Connect(renderMap)