Help only using script once boolvalue true?

So I have this script that turns the players head with the camera, but I want it to disable when the “activated” child is turned false, but I do not know where to put this in the script, any help?

> local Plr = game.Players.LocalPlayer
> repeat
> 	wait()
> until Plr.Character
> repeat
> 	wait()
> until Plr.Character:WaitForChild("Head"):WaitForChild("Neck")
> if script.Activated.Value == true then -- where i tried
> wait(6)
> local Ang = CFrame.Angles
> local aSin = math.asin
> local aTan = math.atan
> local Cam = game.Workspace.CurrentCamera
> local Mouse = Plr:GetMouse()
> local Body = Plr.Character or Plr.CharacterAdded:wait()
> local Head = Body:WaitForChild("Head")
> local Hum = Body:WaitForChild("Humanoid")
> local Core = Body:WaitForChild("HumanoidRootPart")
> local IsR6 = Hum.RigType.Value == 0
> local Trso = Body:WaitForChild("UpperTorso")
> local Neck = Plr.Character:WaitForChild("Head"):WaitForChild("Neck")
> local Waist = Trso:WaitForChild("Waist")
> local MseGuide = false
> local TurnCharacterToMouse = false
> local HeadHorFactor = 1
> local HeadVertFactor = 0.6
> local BodyHorFactor = 0.5
> local BodyVertFactor = 0.4
> local UpdateSpeed = 0.5
> local NeckOrgnC0 = Neck.C0
> local WaistOrgnC0 = not IsR6 and Waist.C0
> Neck.MaxVelocity = 0.3333333333333333
> if TurnCharacterToMouse == true then
> 	HeadHorFactor = 0
> 	BodyHorFactor = 0
> end
> game:GetService("RunService").RenderStepped:Connect(function()
> 	local CamCF = Cam.CoordinateFrame
> 	if (IsR6 and Body.Torso or Body.UpperTorso) ~= nil and Body.Head ~= nil and Plr.Character.Humanoid.Health > 0 then
> 		local TrsoLV = Trso.CFrame.lookVector
> 		local HdPos = Head.CFrame.p
> 		if (IsR6 and Neck or Neck and Waist) and (Cam.CameraSubject:IsDescendantOf(Body) or Cam.CameraSubject:IsDescendantOf(Plr)) then
> 			local Dist, Diff
> 			if not MseGuide then
> 				Dist = (Head.CFrame.p - CamCF.p).magnitude
> 				Diff = Head.CFrame.Y - CamCF.Y
> 				if not IsR6 then
> 					Neck.C0 = Neck.C0:lerp(NeckOrgnC0 * Ang(aSin(Diff / Dist) * HeadVertFactor, -(HdPos - CamCF.p).Unit:Cross(TrsoLV).Y * HeadHorFactor, 0), UpdateSpeed / 2)
> 					Waist.C0 = Waist.C0:lerp(WaistOrgnC0 * Ang(aSin(Diff / Dist) * BodyVertFactor, -(HdPos - CamCF.p).Unit:Cross(TrsoLV).Y * BodyHorFactor, 0), UpdateSpeed / 2)
> 				else
> 					Neck.C0 = Neck.C0:lerp(NeckOrgnC0 * Ang(-(aSin(Diff / Dist) * HeadVertFactor), 0, -(HdPos - CamCF.p).Unit:Cross(TrsoLV).Y * HeadHorFactor), UpdateSpeed / 2)
> 				end
> 			else
> 				local Point = Mouse.Hit.p
> 				Dist = (Head.CFrame.p - Point).magnitude
> 				Diff = Head.CFrame.Y - Point.Y
> 				if not IsR6 then
> 					Neck.C0 = Neck.C0:lerp(NeckOrgnC0 * Ang(-(aTan(Diff / Dist) * HeadVertFactor), (HdPos - Point).Unit:Cross(TrsoLV).Y * HeadHorFactor, 0), UpdateSpeed / 2)
> 					Waist.C0 = Waist.C0:lerp(WaistOrgnC0 * Ang(-(aTan(Diff / Dist) * BodyVertFactor), (HdPos - Point).Unit:Cross(TrsoLV).Y * BodyHorFactor, 0), UpdateSpeed / 2)
> 				else
> 					Neck.C0 = Neck.C0:lerp(NeckOrgnC0 * Ang(aTan(Diff / Dist) * HeadVertFactor, 0, (HdPos - Point).Unit:Cross(TrsoLV).Y * HeadHorFactor), UpdateSpeed / 2)
> 				end
> 			end
> 		end
> 	end
> 	if TurnCharacterToMouse == true then
> 		Hum.AutoRotate = false
> 		Core.CFrame = Core.CFrame:lerp(CFrame.new(Core.Position, Vector3.new(Mouse.Hit.p.x, Core.Position.Y, Mouse.Hit.p.z)), UpdateSpeed / 2)
> 	else
> 		Hum.AutoRotate = true
> 	end
> 	end)
> local Tools = Plr.Backpack:GetChildren()
> local Debounce = false
> function Check()
> 	for i = 1, #Tools do
> 		if Tools[i].ClassName == "Tool" and Tools[i].ToolTip == "Firearm" or Tools[i].ClassName == "Tool" and Tools[i].ToolTip == "Melee" then
> 			Tools[i].Equipped:connect(function()
> 				if Debounce == false then
> 					Debounce = true
> 					TurnCharacterToMouse = true
> 					wait()
> 					Tools[i].Unequipped:connect(function()
> 						Debounce = false
> 						TurnCharacterToMouse = false
> 						MseGuide = false
> 					end)
> 				end
> 			end)
> 		end
> 	end
> end
> Check()
> Plr.Backpack.ChildAdded:connect(function()
> 	Tools = Plr.Backpack:GetChildren()
> 	Check()
> end)
> Plr.Character.Humanoid.Died:connect(function()
> 	script.Disabled = true
> 	end)
> end

This will only check if the value is true once and then it will continue looping indefinitely. What you could do is check on each iteration at either the beginning or end of the loop if the value is still true, and if not then break the loop.

If you want it to be able to resume then I suggest creating and event listener (script.Activated.Changed) and starting or ending the loop based on the new value of the Changed value.

I do not know how I would make that happen though, any help.

Nevermind, I no longer need this, thank you though.