Camera shakes getting bigger over time (EZ Camera Shake Module)

I’m using the EZ Camera Shake Module for creating 3 :ShakeOnce shakes but they get bigger over time (it looks like the magnitude literally stacks). No idea why. Could use help.

Starting, pretty much normal behavior:

Later on, after 30 seconds or so:

local newCamShake = MOD_CAMERASHAKER.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
	Camera.CFrame = camPart.CFrame * shakeCFrame
end)
local function Sculpting(finalRandomSculpt)
	
	humanoid:UnequipTools()
	
	if not isSculpting then
		sculptProgress_MAX = AssignRandomSculpt(sculptProgress_MAX)
	end
	
	isSculpting = true
	
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = camPart.CFrame
	--Camera.FieldOfView = 80
	
	
	inputConnection = UIS.InputBegan:Connect(function(input, gameProcessedEvent)
		proxButtonDesk.Enabled = false
		
		if input.UserInputType == Enum.UserInputType.MouseButton1 and currentProgress < sculptProgress_MAX then
			
			if gameProcessedEvent == false and not sculptDebounce then
				sculptDebounce = true
				
				
				
				camShake = newCamShake
				camShake:Start()
				
				camShake:ShakeOnce(1, 5, 0.2, .6)
				
				BreatheIn:Play()
				sculptAnim:Play()
				sculptAnim:AdjustSpeed(1.5)
				
				sculptAnim:GetMarkerReachedSignal("Hit"):Connect(function()
					sculptAnim:AdjustSpeed(0)
					camShake:ShakeOnce(1, 25, 0, .2)
					task.wait(.1)
					sculptAnim:AdjustSpeed(1.5)
					ClaySmashSound:Play()
					playRandomSound()
					camShake:ShakeOnce(1.5, 40, 0, .3)
					
				end)
				
				sculptAnim:GetMarkerReachedSignal("Whoosh"):Connect(function()
					Swoosh:Play()
					
				end)
				
				
				
				currentProgress += increment
				print(currentProgress)
				
				
				
				
				
				sculptAnim.Stopped:Connect(function()
					if currentProgress >= sculptProgress_MAX then
						local finishedSculpt = RS.Sculpt:Clone()
						finishedSculpt.Parent = player.Backpack
						XPModRemote:FireServer(true)
						print("sculpt is ready")

						currentProgress = 0
						getControls:Enable()
						closeButton.Visible = false
						inputConnection:Disconnect()

						Camera.CFrame = CFrame.Angles(5, 5, 0)
						camShake:Stop()
						Camera.CameraType = Enum.CameraType.Custom
						
						
						isSculpting = false
						sculptAnim:Stop()
						task.wait(.5)
						proxButtonDesk.Enabled = true
						
						
					end
				
				end)
				
				task.wait(sculpt_CD)
				sculptDebounce = false
				
			end
			
			
			
		
		end
	end)
end
1 Like

Are you sure it’s stopping correctly? I don’t see “scult is ready” in output

1 Like

Even after “finishing sclupting” it keeps shaking more when i run the Sculpting() function again

I’m not sure if CameraShaker module was designed to be Started multiple times in the first place, it might be stopping the latest instance only. Try adjusting ShakeOnce magnitude instead.

Ngl, even after leaving only one :ShakeOnce it still gets progressively bigger

Can you send your current code?

local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")

local SG = game:GetService("StarterGui")
local player = game.Players.LocalPlayer or game.Players.PlayerAdded



local playerGUI = player.PlayerGui
local GUI = playerGUI:WaitForChild("ScreenGui")
local closeButton = GUI.CloseButton

local ClaySmashSound = workspace["Clay Smash SFX"]
local BreatheIn = workspace["Breathe In"]
local Swoosh = workspace.Swoosh



local inputConnection
local merchant = workspace.Merchant

local boothName = player.Name.. "'s Booth"
local Camera = workspace.CurrentCamera


local booth 

local proxButtonDesk
local camPart

local re_BoothInfo = RS.BoothInfo

--local booth = RS.BoothToReplicate.SculptingDeskMain_BoxSkin
--local proxButtonDesk = booth.ProximityPrompt

local XPMod = require(RS.Modules.XPDistribution)
local XPModRemote = RS.XPModRemote

 -- 17315844442  
local sculptAnim1 = Instance.new("Animation")
sculptAnim1.AnimationId = "rbxassetid://17339275024"

--17315844442
local TweenService = game:GetService("TweenService")
local SculptVarMOD = require(RS.Modules.SculptVariations)
local MOD_CAMERASHAKER = require(RS.Modules.CameraShaker)

local camShake

local SpecialSounds = workspace.SpecialSounds
local currentSound = nil


local sculptProgress_MAX = 0
local currentProgress = 0
local increment = 50
local sculptDebounce = false
local sculpt_CD = 1

local isSculpting = false

local humanoid = player.Character:WaitForChild("Humanoid")
local sculptAnim = humanoid:LoadAnimation(sculptAnim1)


local getControls = require(player.PlayerScripts:WaitForChild("PlayerModule")):GetControls()
local re_ReplicatingBooth = RS.ReplicatingBooth


re_BoothInfo.OnClientEvent:Connect(function(newBooth)
	booth = newBooth
	local newBooth = workspace.Booths:WaitForChild(boothName)
	local newCamPart = newBooth.CamPart
	local newProxButtonDesk = newBooth.SculptingDeskMain_BoxSkin.ProximityPrompt
	
	camPart = newCamPart
	proxButtonDesk = newProxButtonDesk
	newProxButtonDesk.Enabled = true
end)



local function speedUpgradeReceived(speedUpgr)
	increment = increment + speedUpgr
	print("Upgrade lvl2 received, " .. increment)
end

local function AssignRandomSculpt(num)
	local finalRandomSculpt = SculptVarMOD:GetRandomSculpt(player)
	print(finalRandomSculpt.MaxHits)

	sculptProgress_MAX = finalRandomSculpt.MaxHits
	return sculptProgress_MAX
end



local function playRandomSound()
	local sounds = SpecialSounds:GetChildren()
	if #sounds > 0 then
		local randomSound = sounds[math.random(#sounds)]
		if randomSound:IsA("Sound") then
			if currentSound then
				currentSound:Stop()
				currentSound:Destroy()
			end
			currentSound = randomSound:Clone()
			currentSound.Parent = game.Workspace
			currentSound:Play()
		end
	end
end

local newCamShake = MOD_CAMERASHAKER.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
	Camera.CFrame = camPart.CFrame * shakeCFrame
end)

local function Sculpting(finalRandomSculpt)
	
	humanoid:UnequipTools()
	
	if not isSculpting then
		sculptProgress_MAX = AssignRandomSculpt(sculptProgress_MAX)
	end
	
	isSculpting = true
	
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = camPart.CFrame
	--Camera.FieldOfView = 80
	
	
	inputConnection = UIS.InputBegan:Connect(function(input, gameProcessedEvent)
		proxButtonDesk.Enabled = false
		
		if input.UserInputType == Enum.UserInputType.MouseButton1 and currentProgress < sculptProgress_MAX then
			
			if gameProcessedEvent == false and not sculptDebounce then
				sculptDebounce = true
				
				
				camShake = newCamShake
				camShake:Start()
				
				camShake:ShakeOnce(1, 5, 0.2, .6)
				
				BreatheIn:Play()
				sculptAnim:Play()
				sculptAnim:AdjustSpeed(1.5)
				
				sculptAnim:GetMarkerReachedSignal("Hit"):Connect(function()
	
					sculptAnim:AdjustSpeed(0)
					camShake:ShakeOnce(1, 25, 0, .2)
					
					task.wait(.1)
					
					sculptAnim:AdjustSpeed(1.5)
					ClaySmashSound:Play()
					playRandomSound()
					camShake:ShakeOnce(1.5, 40, 0, .3)
					
				end)
				
				sculptAnim:GetMarkerReachedSignal("Whoosh"):Connect(function()
					Swoosh:Play()
				end)
				
				
				currentProgress += increment
				print(currentProgress)
				
			
				sculptAnim.Stopped:Connect(function()
					if currentProgress >= sculptProgress_MAX then
						
						local finishedSculpt = RS.Sculpt:Clone()
						finishedSculpt.Parent = player.Backpack
						XPModRemote:FireServer(true)
						print("sculpt is ready")

						currentProgress = 0
						getControls:Enable()
						closeButton.Visible = false
						inputConnection:Disconnect()

						Camera.CFrame = CFrame.Angles(5, 5, 0)
						camShake:Stop()
						Camera.CameraType = Enum.CameraType.Custom
						
						isSculpting = false
						sculptAnim:Stop()
						task.wait(.5)
						proxButtonDesk.Enabled = true
						
					end
				
				end)
				
				task.wait(sculpt_CD)
				sculptDebounce = false
				
			end
		end
	end)
end

local function EnableDisableMovement()
	
	getControls:Disable()
	closeButton.Visible = true
	Sculpting()
	print(camPart)
	
	--Camera.CFrame = booth.SculptingDeskMain_BoxSkin.CFrame * CFrame.new(0, 3, 0) * CFrame.Angles(0, math.rad(90), 0)
	player.Character:WaitForChild("Humanoid").RootPart.CFrame = 
		booth.SculptingDeskMain_BoxSkin.CFrame * CFrame.new(-5, 0, 0) * CFrame.Angles(0, math.rad(-90), 0)
	
	-- 
	closeButton.MouseButton1Click:Connect(function()	
		if not sculptAnim.IsPlaying then
			camShake:Stop()
			sculptAnim:Stop()
			getControls:Enable()
			closeButton.Visible = false
			proxButtonDesk.Enabled = true

			Camera.CFrame = CFrame.Angles(5, 5, 0)
			Camera.CameraType = Enum.CameraType.Custom
		else
			print("idk")
			return
		end
		
		if inputConnection then
			inputConnection:Disconnect() 
		end
		
	end)
end

local function sellingSculpttoMerchant()
	
	local sculpt = player.Backpack:FindFirstChild("Sculpt")
	
	if sculpt then
		sculpt:Destroy()
		RS.MerchantGold:FireServer()
		print("has item")
		
	else
		
		print("ur a failure")
		end
		--RS.MerchantGold:FireServer()
end


re_ReplicatingBooth.OnClientEvent:Connect(function()
	EnableDisableMovement()
end)

humanoid.Died:Connect(function()
	if isSculpting then
		camShake:Stop()
		isSculpting = false
		currentProgress = 0
		getControls:Enable()
		closeButton.Visible = false
		inputConnection:Disconnect()
		Camera.CFrame = CFrame.Angles(5, 5, 0)
		Camera.CameraType = Enum.CameraType.Custom
		print("Player died during sculpting, resetting state")
		print(isSculpting)
		task.wait(4)
		proxButtonDesk.Enabled = true
	end

end)

merchant.SellProx.Triggered:Connect(sellingSculpttoMerchant)

RS.SculptSpeedBought.OnClientEvent:Connect(speedUpgradeReceived)





remove camShake:Start() and camShake:Stop() in your code and place it right after newCamShake creation.

local newCamShake = MOD_CAMERASHAKER.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
	Camera.CFrame = camPart.CFrame * shakeCFrame
end)
newCamShake:Start()

You should only start CameraShaker once and theres really no point in stopping it either.

1 Like

I couldn’t get it out of the scope cuz was getting spammed with this:

because I have this at the beginning of Sculpting():

Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = camPart.CFrame

Anyway, it seems to be fixed. Thanks for the help.

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