Help - Visual Bug

The issue occurs in a specific location and angle. When the player is moving at high speed, the car disappears and reappears quickly. I initially thought it was related to StreamingEnabled, but even with it turned off, the problem still happens.

However, when I make any selection, the issue disappears. Yet, this also happens outside of Studio.(In Game)

I don’t think it has anything to do with a camera script, as the only one I use is this one:

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local clientScripts = script.Parent
local camera = workspace.CurrentCamera

local car = clientScripts:FindFirstAncestorOfClass("Model")
local driveSeat = car:WaitForChild("VehicleSeat")

local enabled = false
local heartbeatConnection = nil

local maxTiltAngle = 15
local maxOffset = Vector3.new(0, 8, -15)
local smoothness = 0.1
local baseFoV = 70
local maxFoVIncrease = 30

local function update()
	if camera.CameraType ~= Enum.CameraType.Custom then
		--camera.CameraType = Enum.CameraType.Custom
	end
	if camera.CameraSubject ~= driveSeat then
		camera.CFrame = driveSeat.CFrame
		camera.CameraSubject = driveSeat
	end

	local speed = driveSeat.Velocity.Magnitude
	local normalizedSpeed = math.min(speed / 200, 1)
	
	local positionOffset = Vector3.new(0, 8 - (normalizedSpeed * maxOffset.Y), -10 - (normalizedSpeed * maxOffset.Z))
	local tiltAngle = normalizedSpeed * maxTiltAngle

	local cameraPosition = driveSeat.CFrame.Position + positionOffset
	local tiltCFrame = CFrame.Angles(math.rad(-tiltAngle), 0, 0)
	local newCFrame = CFrame.new(cameraPosition) * tiltCFrame

	local newFoV = baseFoV + (normalizedSpeed * maxFoVIncrease)
	
	camera.CFrame = camera.CFrame:Lerp(newCFrame, smoothness)
	camera.FieldOfView = camera.FieldOfView + (newFoV - camera.FieldOfView) * smoothness
end

local Camera = {}

function Camera:enable()
	if enabled then
		return
	end
	enabled = true

	heartbeatConnection = RunService.Heartbeat:Connect(update)
end

function Camera:disable()
	if not enabled then
		return
	end
	enabled = false

	if heartbeatConnection then
		heartbeatConnection:Disconnect()
		heartbeatConnection = nil
	end
	
	camera.FieldOfView = baseFoV
end

return Camera

you’re dividing by 0 somewhere. Start printing values to debug

I’m pretty certain this isn’t a fault of your own. The fact that selecting the object in the explorer causes it to reappear is already a good sign it’s an issue with the render engine.

It also seems like it occurs in 45-degree increments behind the player. Try placing the player slightly behind the center of the car to see if that fixes anything.

Put a highlight in the model, it’ll act like it’s selected and it won’t disappear. Change the Highlight values so that the color is transparent. I’m sure this isn’t the best fix but it’s a fix nonetheless.

For some reason, it’s my computer. I tested on other devices, and this didn’t happen in any of the tests

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.