How can i fix the client optimisation breaking issue for obby?

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?

You can use Instance:RequestStreamAroundAsync or Instance:SetNetworkOwner to ensure the checkpoints remain loaded in the client’s memory.

do you mean streaming enabled? if though then you can disable it from the workspace

i don’t want players to feel lag too, i still need a perfect performance for both client and server, if i disable streaming enabled i risk to release useless details and leaks client performances.

1 Like

Is my last solution is to migrate to server handling using remote events? like the server handle the request if true request then it return a position else a warning string?