Proper trails for bullets, using Fast Cast module?

I have just added the Fast Cast module to my game, but the trail is not starting from the origin, and instead the first raycast’s position. Any ideas to fix this?

Video (Origin is character’s head) :

FULL Server script:

local character = script.Parent
local fireEvent = game.ReplicatedStorage.ShootEvent
local reloadEvent = game.ReplicatedStorage.ReloadEvent
local fastCast = require(game.ReplicatedStorage.FastCastRedux)
local partCache = require(game.ReplicatedStorage.PartCache)
local bulletsFolder = workspace:FindFirstChild("BulletFolder") or Instance.new("Folder", workspace)
bulletsFolder.Name = "BulletFolder"

local bulletTemplate = game.ReplicatedStorage.Bullet:Clone()

--local bulletTemplate = Instance.new("Part")
--bulletTemplate.Anchored = true
--bulletTemplate.CanCollide = false
--bulletTemplate.Shape = "Ball"
--bulletTemplate.Size = Vector3.new(0.25, 0.25, 0.25)
--bulletTemplate.Material = Enum.Material.Metal

--local attach0 = Instance.new("Attachment")
--attach0.Name = "Attachment0"
--attach0.Parent = bulletTemplate
--attach0.Position = Vector3.new(0, 0.055, 0)

--local attach1 = Instance.new("Attachment")
--attach1.Name = "Attachment1"
--attach1.Parent = bulletTemplate
--attach1.Position = Vector3.new(0, -0.055, 0)

--local trailPart = Instance.new("Trail")
--trailPart.Parent = bulletTemplate	
--trailPart.Attachment0 = bulletTemplate.Attachment0
--trailPart.Attachment1 = bulletTemplate.Attachment1
--trailPart.Lifetime = 0.1

--fastCast.VisualizeCasts = true

local caster = fastCast.new()

local castParams = RaycastParams.new()
castParams.FilterType = Enum.RaycastFilterType.Blacklist
castParams.IgnoreWater = true

local bulletCache = partCache.new(bulletTemplate, 100, bulletsFolder)

castParams.FilterDescendantsInstances = {character, bulletsFolder}

local castBehaviour = fastCast:newBehavior()
castBehaviour.RaycastParams = castParams
castBehaviour.Acceleration = Vector3.new(0, - workspace.Gravity, 0)
castBehaviour.AutoIgnoreContainer = false
castBehaviour.CosmeticBulletContainer = bulletsFolder
castBehaviour.CosmeticBulletProvider = bulletCache

local totalAmmo = 5

local ammoLeft = totalAmmo
local reloading = false

script.Parent:SetAttribute("Reloading", false)

local function reload()
	if reloading then return end
	reloading = true
	script.Parent:SetAttribute("Reloading", true)
	task.wait(1)
	ammoLeft = totalAmmo
	reloading = false
	script.Parent:SetAttribute("Reloading", false)
end

local function onLengthChanged(cast, lastPoint, direction, length, velocity, bullet)
	if bullet then
		local bulletLength = bullet.Size.Z / 2
		local offset = CFrame.new(0, 0, -(length - bulletLength))
		bullet.CFrame = CFrame.lookAt(lastPoint, lastPoint + direction):ToWorldSpace(offset)
		
	end
end

local function onRayHit(cast, result, velocity, bullet)
	local hit = result.Instance
	
	local character = hit:FindFirstAncestorWhichIsA("Model")
	if character and character:FindFirstChild("Humanoid") then
		character.Humanoid:TakeDamage(50)
	end
	
	delay(2, function()
		bulletCache:ReturnPart(bullet)
	end)
end

local function fire(player, shootPos, direction)
	if ammoLeft > 0 and not reloading then
		local origin = shootPos
		
		caster:Fire(origin, direction, 300, castBehaviour)
		ammoLeft -= 1
	end
end

fireEvent.OnServerEvent:Connect(fire)
reloadEvent.OnServerEvent:Connect(reload)
caster.LengthChanged:Connect(onLengthChanged)
caster.RayHit:Connect(onRayHit)

I don’t think it’s necessary, but I can add client side code if needed.

My best guess is that when the bullet visuals are first parented only after the first ray step has already taken place. If this however isn’t the case then check if StreamingEnabled is active, this may create slight delays in replication leading the client missing the first step :smiley:

I’m a little confused, I understand what the code does, but how can I implement it into my code? Im pretty new to fastCasts, so any help would be appreciated.