How do I just make the EZ Camera Shake module work?

I have been trying to make the EZ Camera Shake module to shake the camera when I punch an enemy, I don’t know how to make Module Scripts work, Neither have I ever used one before, Here is my Script.

local CameraShaker = require(game.ReplicatedStorage.CameraShaker)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage:WaitForChild("Punch")

Remote.OnServerEvent:Connect(function(Player)
	local Character = Player.Character
	local Humanoid = Character:WaitForChild("Humanoid")

	local Params = RaycastParams.new()
	Params.FilterType = Enum.RaycastFilterType.Blacklist
	Params.FilterDescendantsInstances = {Character}

	local Origin = Character.HumanoidRootPart.Position
	local Direction = Character.HumanoidRootPart.CFrame.LookVector * 3 -- Range of Punch in studs.
	local Result = workspace:Raycast(Origin, Direction, Params)
	
	if Result then
		local Damage = math.random(5, 10) -- Damage of Punch.
		local Part = Result.Instance
		local Enemy = Part.Parent:FindFirstChild("Humanoid") or Part.Parent.Parent:FindFirstChild("Humanoid")
		
		if Enemy and Enemy:GetState() ~= Enum.HumanoidStateType.Dead then
			Enemy:TakeDamage(Damage)
			game.Workspace.SFX.PunchSFX:Play()
			CameraShaker:ShakeOnce()
		end
	end
end)

1 Like
local CameraShaker = require(game.ReplicatedStorage.CameraShaker)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage:WaitForChild("Punch")
local Camera = workspace.CurrentCamera

local Shaker = CameraShaker.new(201, function(shakeCf)
    Camera.CFrame *= shakeCf
end)

Remote.OnServerEvent:Connect(function(Player)
	local Character = Player.Character
	local Humanoid = Character:WaitForChild("Humanoid")

	local Params = RaycastParams.new()
	Params.FilterType = Enum.RaycastFilterType.Blacklist
	Params.FilterDescendantsInstances = {Character}

	local Origin = Character.HumanoidRootPart.Position
	local Direction = Character.HumanoidRootPart.CFrame.LookVector * 3 -- Range of Punch in studs.
	local Result = workspace:Raycast(Origin, Direction, Params)
	
	if Result then
		local Damage = math.random(5, 10) -- Damage of Punch.
		local Part = Result.Instance
		local Enemy = Part.Parent:FindFirstChild("Humanoid") or Part.Parent.Parent:FindFirstChild("Humanoid")
		
		if Enemy and Enemy:GetState() ~= Enum.HumanoidStateType.Dead then
			Enemy:TakeDamage(Damage)
			game.Workspace.SFX.PunchSFX:Play()
			Shaker:ShakeOnce(CameraShakers.Presets.Explosion)
		end
	end
end)

Essentially you have to get construct a new instance of the CameraShaker module with a render priority value (201 which runs after the camera updates) and a function which receives the shake cframe which at its basic form you multiply with the player’s camera’s cframe. And then you call the shaking methods (ShakeOnce, ShakeSustain) from the previously constructed instance

1 Like

More info: I haven’t touched the module script and just moved it

1 Like

Thanks! I completely forgot to reference the camera!

1 Like

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