FastCast - Laggy Projectiles

Hey, I’ve recently been trying to make projectiles in my game instead of hit scan. Currently, I have a module called FastCast which I heard was pretty good when used correctly, however, the projectiles seem to be extremely laggy.

For anyone curious, the server FPS has been between 56-60 the entire time, but the problem still persists.

Another note is that, whether or not the projectile is anchored or unanchored, it still lags regardless.

FastCast: API: FastCast API

Code:

--[[ CASTER FUNCTIONS ]]--

Caster.LengthChanged:Connect(function(ActiveCast, LastPoint, RayDir, Displacement, SegmentVelocity, CosmeticBulletObject)

	local NewPos = LastPoint + (RayDir * Displacement)

	CosmeticBulletObject.Position = NewPos
end)

Caster.RayHit:Connect(function(ActiveCast,RaycastResult,SegmentVelocity,CosmeticBulletObject)
	if ActiveCast.UserData["ExplodeOnImpact"] == true then
		
		CosmeticBulletObject:Destroy()
		
		Explode(ActiveCast.UserData["Player"],ActiveCast.UserData["Weapon"],RaycastResult.Position)
	else
		CosmeticBulletObject.Anchored = false
		CosmeticBulletObject.CanCollide = true
	end
end)

function FireProjectile(Player,Weapon,CamCFrame)
	
	local Offset = WeaponStats[Weapon]["Offset"]
	local Behavior = ProjectileBehaviors[Weapon]
	
	CastParams.FilterDescendantsInstances = {Filter}
	
	local ActiveCast = Caster:Fire((CamCFrame * CFrame.new(Offset)).Position, CamCFrame.LookVector, WeaponStats[Weapon]["Velocity"], Behavior)
	
	ActiveCast.UserData = {
		["Player"] = Player,
		["Weapon"] = Weapon,
		["ExplodeOnImpact"] = WeaponStats[Weapon]["ExplodeOnImpact"],
	}
end

This issue was just fixed by me. For anyone who happens to stumble upon this in the future, just don’t visualize the projectile on the server, and only visualize it on the client. So like if you’re firing a projectile just fire a remote event to all the clients telling what the exact path and parameters are, otherwise replication issues will make it laggy.

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