Sorry for spamming the site but I'm close to where I want this game to be at the moment. I want to test if the gun is clipping through a wall. The way I want to go about this is casting a ray from the tip of the gun towards the head of the character. If it intersects a part (so if the gun is clipping something) it won't fire the gun. This is what I tried for the sake of trying (pls dont bully me JesseSong)
function CheckCollision()
local rayOrigin = FirePointObject.Position
local rayDirection = script.Parent.Parent.Head
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {script.Parent} -- gun
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
if raycastResult then
return
end
end
I get an error saying Unable to cast Instance to Vector3 so I probably got the rayDirection wrong. Any help is appreciated.

1 comment
You also need to multiply that direction by the range of your gun in studs.