Basically , roblox clients are now optimised to remove parts a bit too far away. However it gets an issue for me and my checkpoint selection system:
-- Wait for stats
local LocalPlayer = game.Players.LocalPlayer
local leaderstats = LocalPlayer:WaitForChild("leaderstats",3)
local Stages
local success,errorm = pcall(function()
Stages = leaderstats:WaitForChild("Stage",3)
end)
-- Save memory
if success then
success = nil
errorm = nil
else
print(errorm)
success = nil
errorm = nil
end
local LocalStages = Stages.Value
local MaxStages = #workspace.Checkpoints:GetChildren()
-- Get the selection frame
local Frame = script.Parent.Frame
local Selection = Frame.Selection
if not Stages then
Stages = leaderstats:WaitForChild("Stage",6)
Stages:GetPropertyChangedSignal("Value"):Connect(function()
LocalStages = leaderstats.Stage.Value
Selection.Number.Text = LocalStages
end)
else
Stages:GetPropertyChangedSignal("Value"):Connect(function()
local success,errorm = pcall(function()
LocalStages = leaderstats:WaitForChild("Stage",2).Value
end)
if not success then
print("Failed to get stage value: "..errorm)
success = nil
errorm = nil
LocalStages = 0
end
if success then
success = nil
errorm = nil
end
Selection.Number.Text = LocalStages
end)
end
function TeleportToCheckpoint(stage)
if not stage then return end
if stage:IsA("Model") then
if not stage.PrimaryPart then
warn("No primary part can't tp")
return
end
LocalPlayer.Character:MoveTo(workspace.Checkpoints[tostring(LocalStages)].PrimaryPart.Position)
else
LocalPlayer.Character:MoveTo(workspace.Checkpoints[tostring(LocalStages)].Position)
end
end
-- Update the text to the value
Selection.Number.Text = LocalStages
Selection.Last.MouseButton1Click:Connect(function()
local success,errorm = pcall(function()
if LocalStages <= 0 then
LocalStages = leaderstats.Stage.Value
if workspace.Checkpoints:FindFirstChild(tostring(LocalStages)) then
TeleportToCheckpoint(workspace.Checkpoints[tostring(LocalStages)])
Selection.Number.Text = LocalStages
else
LocalStages = 0
Selection.Number.Text = LocalStages
TeleportToCheckpoint(workspace.Checkpoints[tostring(LocalStages)])
end
return
end
if LocalStages <= leaderstats.Stage.Value then
LocalStages -= 1
Selection.Number.Text = LocalStages
TeleportToCheckpoint(workspace.Checkpoints[tostring(LocalStages)])
end
end)
if not success and errorm then
print("Failed to skip stage : "..errorm)
LocalStages = leaderstats.Stage.Value
Selection.Number.Text = LocalStages
if workspace.Checkpoints:FindFirstChild(tostring(LocalStages)) then
TeleportToCheckpoint(workspace.Checkpoints[tostring(LocalStages)])
end
end
end)
Selection.Next.MouseButton1Click:Connect(function()
local success,errorm = pcall(function()
if LocalStages >= MaxStages then
LocalStages = 0
Selection.Number.Text = LocalStages
TeleportToCheckpoint(workspace.Checkpoints[tostring(LocalStages)])
return
end
if LocalStages >= leaderstats.Stage.Value then
LocalStages = 0
Selection.Number.Text = LocalStages
TeleportToCheckpoint(workspace.Checkpoints[tostring(LocalStages)])
return
end
if LocalStages < MaxStages then
if workspace.Checkpoints:FindFirstChild(tostring(LocalStages + 1)) then
LocalStages += 1
Selection.Number.Text = LocalStages
TeleportToCheckpoint(workspace.Checkpoints[tostring(LocalStages)])
else
LocalStages = 0
Selection.Number.Text = LocalStages
TeleportToCheckpoint(workspace.Checkpoints[tostring(LocalStages)])
end
end
end)
if not success and errorm then
print("Failed to skip stage : "..errorm)
LocalStages = leaderstats.Stage.Value
Selection.Number.Text = LocalStages
if workspace.Checkpoints:FindFirstChild(tostring(LocalStages)) then
TeleportToCheckpoint(workspace.Checkpoints[tostring(LocalStages)])
end
end
end)
How can i fix this issue?