--module is tagged "EffectModule"
--client gets all modules with this tag and calls initialize()

local CameraShaker = require(game.ReplicatedStorage.Modules.CameraShaker)
local camera = game.Workspace.CurrentCamera

local module = {}
	
local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
	camera.CFrame = camera.CFrame * shakeCFrame
end)

camShake:Start()

local minimumDistance = 300

function module.Initialize()
	while script.Parent and script.Parent ~= nil do
		wait(math.random(60,120))
		local distance = (camera.CFrame.Position - script.Parent.Position).Magnitude
		if distance <= minimumDistance then
			camShake:Shake(CameraShaker.Presets.Earthquake)
		end
			script.Parent.Erupt:Play()
			script.Parent.ParticleEmitter.Enabled = true
			wait(8)
			script.Parent.ParticleEmitter.Enabled = false
	end
end

return module
