My Camera Script randomly bugs out

Hello scripters! I’ve been using this Camera Script recently, however it has been bugging out. Causing it to freeze in place and not follow the Character. The view is top-down, here is my game:

I really don’t have a clue why it’s acting like this, perhaps the script itself is inefficient? could it be structured better?

Local Script in StarterCharacterScript:

wait()
require(script.Parent.StateHandler):Init()

Moduel Script in StarterCharacterScript:

-- // REQUIRES \\ --

local CameraHandler = require(script.CameraHandler)
local FaceMouse = require(script.FaceMouse)

-- // CONSTANTS \\ --

local plr = game.Players.LocalPlayer
local StarterGui = game:GetService("StarterGui")

-- // EXECUTABLES \\ --

local SH = {}

local function RegenerateProperites(char)
	local Torso = char:WaitForChild("UpperTorso")
	local hum = char:WaitForChild("Humanoid")
	
	hum.BreakJointsOnDeath = false
	
	CameraHandler:Follow(Torso)
	
	FaceMouse:RotateToMouse(char)
end

function SH:Init()
	self.Init = nil
	
	-- PRESET INCASE CHARACTER ALREADY EXISTS
	if plr.Character then
		RegenerateProperites(plr.Character)
	end
	
	-- SETUP CHARACTER ON RESPAWNS
	plr.CharacterAdded:Connect(RegenerateProperites)
end

return SH
1 Like

I have played this game about a week ago and it’s really good, but for camera scripts I think you should position the camera on the characters head and add a position. Then the camera should update when the render stepped event fires.

I know what you mean, however I do like the effect with this script that the camera tilts depending on the mouses position and the character looking at your mouse.

I think you can still do that but continuing to update the position each time and also adding the mouse position.

Do you know how I can do that?

Sorry, I was asleep. So what you can do is have your function and have it run whenever the render stepped event fires using RunService.RenderStepped that’s when the camera will update.