The topic explains itself. I am making a viewmodel that shoots, but the viewmodel keeps getting in the way.
I made a typical raycast system that goes from the origin (the muzzle) and goes to the position the mouse clicks at.
local Origin = Framework.Viewmodel.Muzzle.Position
local Direction = (Mouse.Hit.p - Origin)
Params.FilterDescendantsInstances = {Character, Framework.Viewmodel} -- The Params are already stated earlier on in the script
local Result = game.Workspace:Raycast(Framework.Viewmodel.Muzzle.Position, Direction * Framework.Module.Bullet_Distance, Params)
-- PART CHECK --
local Part_Hit
if Result ~= nil then
Part_Hit = Result.Instance -- This is used for the remote event to fire the server
end
-- HUMANOID CHECK --
local IsHumanoid
local Headshot
if Result then
if Result.Instance.Name == "Handle" then
IsHumanoid = Result.Instance.Parent.Parent:FindFirstChild("Humanoid")
elseif Result.Instance.Parent:FindFirstChild("Humanoid") then
IsHumanoid = Result.Instance.Parent:FindFirstChild("Humanoid")
if Result.Instance.Name == "Head" then
Headshot = true
end
end
end
This code is in a function in a local script.
This is the code I use. If anyone can give me a solution or any ideas I would greatly appreciate it.