Hello! I was trying to make my first gun but then I got stuck on the raycasting part. The gun seems to work decent but something the raycast it’s not how it should be. Even if I have them mouse on top a character, the raycasting goes besides it, and it doesn’t touch it. Anyone who could help me?
This is the code of the raycast part.
HitPositon = Mouse.Hit
ShootPart = the on the gun where the bullet comes out
local function rayCasting(HitPosition)
local currentRay = Ray.new(ShootPart.Position, HitPosition.LookVector * 100)
local HitPart, HitPartPosition = game.Workspace:FindPartOnRay(currentRay)
return HitPart, HitPartPosition, currentRay
This is an image of house the raycast goes besides the character, into the void…