Question for a shoulder camera script

Hello, So I made this over shoulder camera script and what it does is, whenever a player equips a tool, the script (local) will check if a bool value exist, if it does then it will check if the the bool value is “true” if it is, then the shoulder camera thing will happen, i used a module script to make it easier for me and that local script is located in starterplayerScripts,

Script:

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)

local Module = require(ReplicatedStorage:WaitForChild(“EnhancedCameraSystem”))

local Player = game.Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()

while wait() do
if Character:FindFirstChildOfClass(“Tool”) then
local Tool = Character:FindFirstChildOfClass(“Tool”)
if Tool:FindFirstChild(“IsWeapon”) then
if Tool.IsWeapon.Value == true then
Module:Alignment(true)
Module:CameraMode(“Reset”)
else
Module:Alignment(false)
end
else
Module:Alignment(false)
end
else
Module:Alignment(false)
end
end

So I am new to this forum and I am not good with catagories, and I don’t want this topic to be moderated like my other last topic so if you have any suggestions on what to do with the code I wrote then please reply for what good changes I should do to it because I am not sure if it woud fully work.

I am also using leonightsTV’s Camera system module [Enhanced Camera System - Roblox] so yeah, go search it up for further inspection

Its nice that you included a script, but thats script that controls the module, we need the source of the module. Also you forgot to quote your script.

huh? I don’t understand, is the script fine?

I suggest you ditch the while wait() do and make a child added event.
This is so the script isn’t active all the time because this code would be running every 0.3 seconds.
Now it would only run when a tool is parented or removed from the character.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Module = require(ReplicatedStorage:WaitForChild("EnhancedCameraSystem"))

local Player = game.Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()

Character.ChildAdded:Connect(function(tool)
	if tool:IsA("Tool") then
		if tool:FindFirstChild("IsWeapon") then
			if tool.IsWeapon.Value == true then
				Module:Alignment(true)
				Module:CameraMode("Reset")
			else
				Module:Alignment(false)
			end
		else
			Module:Alignment(false)
		end
	end
end)

Character.ChildRemoved:Connect(function(tool)
	if tool:IsA("Tool") then
		Module:Alignment(false)
	end
end)