The bullets just hit the ground

I need help with this issue , whenever i shoot the bullets just go straight to the ground.

CODE

FastCast.VisualizeCasts = true -- good for debugging when you dont hve bullet
local caster = FastCast.new() -- creates this once for your gun
local provider = PartCache.new(pellet, 100, pelletsFolder)

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

local behavior = FastCast.newBehavior()
behavior.RaycastParams = castParams
behavior.CosmeticBulletProvider = provider
behavior.CosmeticBulletContainer = pelletsFolder
behavior.Acceleration = Vector3.new(0, -workspace.Gravity, 0)
local camera = workspace.CurrentCamera

local mouse = player:GetMouse()

local pos = UIS:GetMouseLocation()
local ray = camera:ViewportPointToRay(pos.X,pos.Y)
local function GetMousePos(unitRay)
	local ori, dir = unitRay.Origin, unitRay.Direction * framework.module.MAX_DIST

	local result = workspace:Raycast(ori, dir, castParams)
	return result and result.Position or ori + dir
end

local function Fire(direction)
	local RNG = Random.new() -- Put these two variables on top, somewhere near all your other variables.
	local TAU = math.pi * 2

	local directionalCF = CFrame.new(Vector3.new(), direction) -- put your dir variable here
	local spreadDirection = CFrame.fromOrientation(0, 0, math.random(0, math.pi * 2))
	local spreadAngle = CFrame.fromOrientation(math.rad(math.random(framework.module.MIN_SPREAD, framework.module.MAX_SPREAD)), 0, 0)
	local direction = (directionalCF * CFrame.fromOrientation(0, 0, RNG:NextNumber(0, TAU)) * CFrame.fromOrientation(math.rad(RNG:NextNumber(framework.module.MIN_SPREAD, framework.module.MAX_SPREAD)), 0, 0)).LookVector * framework.module.MAX_DIST

	caster:Fire(framework.viewmodel.Importants.Muzzle.FirePoint.WorldPosition, direction, framework.module.MAX_DIST, behavior)
end

	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		if character and framework.viewmodel and framework.module and framework.module.ammo ~= 0 and debounce == false and isReloading ~= true and canShoot == true then
				local pos = GetMousePos(ray)
				local direction = (pos - framework.viewmodel.Importants.Muzzle.FirePoint.WorldPosition).Unit

				for i = 1, 1 do
				Fire(direction)
				Shoot()
			end
caster.LengthChanged:Connect(function(cast, lastPoint, dir, displacment, segVel, pellet)
	pellet.CFrame = CFrame.lookAt(lastPoint + (dir * displacment), lastPoint)
end)

caster.RayHit:Connect(function(cast, result, segVel, pellet)
	if result.Instance then 
		local character = result.Instance:FindFirstAncestorWhichIsA("Model")
		local humanoid = character and character:FindFirstChild("Humanoid")
		if humanoid then
			humanoid:TakeDamage(10)
			provider:ReturnPart(pellet)
		else
			wait(1)
			provider:ReturnPart(pellet)
		end
	end
end)

try to set its network ownership to nil ( server )

To everyone the issue is fixed

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