Player is destroyed after zooming out to far

so I’m making a game similar to diep.io and added a couple new upgrades of my own. One of these upgrades lets the player zoom out their camera further. but if the camera zooms out to far (42.914 studs) every basepart under the player’s character is destroyed on the client, which is bad. Anyway I’m using a custom character I made and a custom camera script I found and edited a bit

local camera = game.Workspace:WaitForChild("Camera")
local Player = game.Players.LocalPlayer
local char = script.Parent or game.Players.LocalPlayer.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")

local Mouse = Player:GetMouse()

local distance = 15

local minDistance = 10
local maxDistance = game.Players.LocalPlayer:WaitForChild("CameraZoom").Value + 30

local RunService = game:GetService("RunService")

camera.CameraType = Enum.CameraType.Scriptable
RunService.RenderStepped:Connect(function()
	
	local Pivot = char:GetPivot().Position

	camera.CFrame = CFrame.lookAt(Pivot + Vector3.new(0, distance, 0), Pivot)
	local RootPos, MousePos = hrp.Position, Mouse.Hit.Position
	hrp.CFrame = CFrame.new(RootPos, Vector3.new(MousePos.X, RootPos.Y, MousePos.Z))
	
end)

mouse.WheelBackward:Connect(function()
	maxDistance = game.Players.LocalPlayer:FindFirstChild("CameraZoom").Value + 30
	if distance <= maxDistance then
		distance += 1
	end
end)
mouse.WheelForward:Connect(function()
	maxDistance = game.Players.LocalPlayer:FindFirstChild("CameraZoom").Value + 30
	if distance >= minDistance then
		distance -= 1
	end
end)

I turned off StreamingEnabled under workspace and I’m playing on maximum graphics. I am hoping the problem is coming from the script but I’m not sure so sorry if I mislabeled it’s category. Thanks!

I’m assuming that the parts are falling past the “FallenPartsDestroyHeight” setting of workspace, which destroys parts if they past the assigned height, so try changing to something “-5000” hope this helps.

1 Like

you can assign this to nan by doing workspace.FallenPartsDestroyHeight = 0/0

this will disable the FallenPartsDestroyHeight feature

1 Like

oh ok, thanks for correcting me.

1 Like

unfortunately, neither of the answers solved the issue. I Tried getting rid of the custom character but nothing changed

You could try loading the BasePart’s on the server and see if thats helps (unless there already loaded on the server.)

1 Like

could you elaborate further please?