script.Parent.Fire.OnServerEvent:Connect(function(player,mousePos)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {player.Character}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(script.Parent.Handle.Position,(mousePos - script.Parent.Handle.Position)*300,raycastParams)
if raycastResult then
local hitpart = raycastResult.Instance
local model = hitpart:FindFirstAncestorOfClass("Model")
if model then
if model:FindFirstChild("Humanoid") then
model.Humanoid.Health -= 15
end
end
end
end)
I use a mixture of PartCache and FastCast from @ EtiTheSpirit.
Somewhere in the depths of the library are sample guns which use both modules.
1 Like