I need to detect all the Player’s Characters inside the game EXCEPT MINE! (Because sometimes the tool detects my own Character)
How can I do that in a Local Script?
local OverlapParam = OverlapParams.new()
OverlapParam.FilterDescendantsInstances = {workspace.Nods} -- I need to to detect the characters to make them hitable and make the local character not hitable
OverlapParam.FilterType = Enum.RaycastFilterType.Whitelist
local filteredChars = {workspace.Nods}
for _, plr in pairs(game.Players:GetPlayers()) do
local char = plr.Character or plr.CharacterAdded:Wait()
if char == game.Players.LocalPlayer.Character then continue end
table.insert(filteredChars, char)
end
local Player = game.Players.LocalPlayer
for _, Char in pairs(game.Workspace:GetChildren())do
if Char:IsA("Model") and game.Players:FindFirstChild(Char.Name) and not Char.Name == Player.Name then
print(Char.Name)
end
end
local AbleToHitTable = {}
for index, player in pairs(game:GetService("Players"):GetPlayers()) do
local char = player.Character or player.CharacterAdded:Wait()
table.insert(AbleToHitTable, char)
end
local MyOwnCharacterIndex = table.find(AbleToHitTable, Character) --Character represents my LocalPlayer's Character
table.remove(AbleToHitTable, MyOwnCharacterIndex)
table.insert(AbleToHitTable, workspace.Nods)
local OverlapParam = OverlapParams.new()
OverlapParam.FilterDescendantsInstances = AbleToHitTable
OverlapParam.FilterType = Enum.RaycastFilterType.Whitelist
This is how I fixed it! Thank you guys for the help!