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!