--[[
local shakeMagnitude = 0.5 -- Adjust this to change the intensity of the shake
local shakeSpeed = 0.05 -- Adjust this to change the speed of the shake
local rotationMagnitude = 0.05 -- Adjust this to change the intensity of the rotation*


local Shakes = {}


local Time = 0


local function GenerateShakeValue(shake)
	local Multiplier = shake["TimeLeft"] / shake["Duration"]
	local X = math.noise(Time + math.random(), 0, 0) * shakeMagnitude * Multiplier
	local Y = math.noise(0, Time + math.random(), 0) * shakeMagnitude * Multiplier
	local Z = math.noise(0, 0, Time + math.random()) * shakeMagnitude * Multiplier

	local Pitch = math.noise(Time + math.random(), 0, 0) * rotationMagnitude * Multiplier
	local Yaw = math.noise(0, Time + math.random(), 0) * rotationMagnitude * Multiplier
	local Roll = math.noise(0, 0, Time + math.random()) * rotationMagnitude * Multiplier


	local OffsetVector = Vector3.new(X,Y,Z)
	local CFrameAngles = CFrame.Angles(Pitch, Yaw, Roll)

	return OffsetVector, CFrameAngles
end

local function NewShake(Power, Duration)
	local shake = {}
	shake["Duration"] = Duration
	shake["Power"] = Power
	shake["TimeLeft"] = shake["Duration"]
	table.insert(Shakes, shake)
end




local BShake = GUI.Shake
BShake.MouseButton1Click:Connect(function()
end)




while true do
	local step = RS.RenderStepped:Wait()
	if #Shakes == 0 then continue end
	--print("Shakes happenings !")


	Time = Time + shakeSpeed * step


	--remove time from Shakes
	for i, child in ipairs(Shakes) do
		if child["TimeLeft"] <= 0 then  table.remove(Shakes, table.find(Shakes, child)) continue end
		child["TimeLeft"] -= step
		--print("A SHAKE RIGHT HERE")
	end


	local SumCameraOffset, SumCFrameAngles = Vector3.new(0,0,0), CFrame.Angles(0,0,0)

	for i, child in ipairs(Shakes) do
		local ChildCameraOffset,ChildCFramesAngles = GenerateShakeValue(child)
		print(ChildCameraOffset)
		SumCameraOffset += ChildCameraOffset
		SumCFrameAngles *= ChildCFramesAngles
	end



	--Final step of applying the final camera shake
	--	print(SumCameraOffset)
	--	print(SumCFrameAngles)
	Humanoid.CameraOffset = SumCameraOffset
	workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * SumCFrameAngles
end
--]]