Hello i recently started making a fps game and added aim system however it detects the player head instead of the enemy’s head
here is the video:
here is the script:
SS.OnServerEvent:Connect(function(player, mouse, attc_pos, tpp_flash)
local DIR = (mouse - attc_pos).Unit
local DIS = (mouse - attc_pos).Magnitude
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = blacklist
local result = workspace:Raycast(attc_pos, DIR * 300, raycastParams)
tpp_flash.Enabled = true
tpp_flash.flash_img.Rotation = math.random(-90, 90)
if result then
local hitpart = result.Instance
local char = hitpart.Parent
local human = char:FindFirstChild("Humanoid")
local DH = require(script.DH)
local bodyparts = hitpart.Name
if char.Name ~= player.Name and human then
human:TakeDamage(DH.damage(bodyparts))
if human.Health <= 0 then
if human.Health ~= -DH.damage(bodyparts) then
if players:FindFirstChild(char.Name) then
players[player.Name].leaderstats.Kills.Value += 1
players[char.Name].leaderstats.Deaths.Value += 1
end
end
end
end
end
task.wait(.1)
tpp_flash.Enabled = false
end)
It only stops the player firing into the FilterDescendantsInstances. So all other players are not in it and can still hit you. It merges your blacklist with the character of the player who is shooting, so it only ignores everything that is in that player’s character, not all players. But give it a try
If you form a new tuple by putting an existing tuple in the beginning and other values after the existing tuple, only the first value in the existing tuple will be in the new tuple.
With your code, RaycastParams.FilterDescendants instances would only contain the first Instance in blacklist, and player.Character.
Thus, if you want to use a tuple in forming a new tuple, put it at the end.