I want to add spread to my guns but i don’t know how to add it, can someone help me?

This is my code for calculating variables for the raycast

local Origin = FirePointObject.WorldPosition
local Direction = (direction-Origin).Unit * Settings.MAX_DIST
local Raycast = workspace:Raycast(Origin, Direction)
local result = Raycast or {Position = Origin+Direction}

-- Create a random number generator
local rng = Random.new()
-- Define the minimum and maximum angles of the spread
local minSpread = 0
local maxSpread = 6
-- Specify the initial direction vector (CHANGE THIS TO YOUR OWN CODE)
local direction = Vector3.new(1, 0, 0)
-- Apply a random rotation around the z-axis and a random spread around the direction vector
local rotation = CFrame.Angles(0, 0, rng:NextNumber(0, 2*math.pi))
local spread = CFrame.fromAxisAngle(direction, math.rad(rng:NextNumber(minSpread, maxSpread)))
-- Apply the rotation and spread to the direction vector
direction = direction + (rotation * spread).LookVector -- OP's solution