Bullets get flung up close

whenever I shoot up close to a object, my bullet gets flung:

this is the code am using to check the end position of bullet:

shurkienModule.cast(Shurkien, Player:GetMouse().Hit.Position, 10)

the module just uses cframe to make the projectile go to the end position, so i dont think thats the problem.

2 Likes

Is the name actually shurkien or did you spell shuriken wrong?

yeah, thats a typo, but the name hasent got anything to do with this error.

1 Like

in that case i dont know whats wrong. sorry

Show the code for the module. It could be the problem even if you don’t think it is.

I’ve been testing out magnitude, to check if the mouse.target is like 1 magnitude and it will count it as a hit instantly instead of spawning a projectile, but here is the module:

function module.cast(gun, endpos, velocity)
	local spawnpos = gun.Handle

	local projectile = ReplicatedStorage.projectile.shuriken:Clone()
	projectile.Parent = workspace
	projectile.CFrame = CFrame.new(spawnpos.Position, endpos)

	local Loop

	Loop = RunService.RenderStepped:Connect(function(dt)
		projectile.CFrame *= CFrame.new(0, 0, -velocity * (dt * 60))
		if (projectile.Position - spawnpos.Position).Magnitude > 5000 then
			projectile:Destroy()
			Loop:Disconnect()
		end
	end)
end

It’s probably because the function you showed is just using physics to decide what to do next. So when it hits the player’s head it just follows the rules of physics and bounces off. What is your desired result? Do you want it to destroy itself when it hits the head?

No as I have previously made fps frameworks and know how to make a working one but I always had this problem like if there was 2 people having a close fight their bullets would just bounce off and they have to step back to actually damage each other, but I think this magnitude thing might solve it.

Irs because however you’re finding the direction, you’re looking from somewhere other than the exact center of the camera. Since they start aiming up when you get close, you know that point is lower than the camera.

image