so in my hitbox system i use a touched event on my hitbox part along with the argument other for the part touched and say that the player character touched is other.Parent . this usually returns errors when im trying to do something like model:FindFirstChildOfClass(“Humanoid”) because it detects all sorts of baseparts in the model, like accesories. what is the best way to only register one of the 7 body parts of the r6 character? (6 + HumanoidRootPart)
(yes, this might be an easy question, but i cant think of anything)
if i understand this post correctly, then you’re dealing with the same issue i was dealing with.
the fix to this is:
local table = {}
x.Touched:Connect ...
local target = -- your target
if table.find(table, target) then return end -- or continue if you're using a for loop
table.insert(table, target)
-- and after everything is done (cooldowns or anything)
table.remove(table, target) or table = {} -- if you're using a for loop, use the table = {} outside the for loop, otherwise it will not work
if i misunderstood this please tell me so i’m not throwing useless help attempts
my issue isnt a hitlist, my issue is that when i do
part.Touched:Connect(function(other)
local character = other.Parent
end)
character isnt always the player model, but most of the time a bodypart, or an accesory (alr tried setting canTouch of all baseparts with cancollide off from the character and still didnt fix the issue)
hmm
what about this?
part.Touched:Connect(function(other)
if other.Parent:FindFirstChild("Humanoid") or other.Parent:FindFirstChild("Character") then -- i'm not sure if :FindFirstChild("Character") will work
local character = other.Parent
end)
this should work, since that variable gets created once the part finds a humanoid
you can use Players:GetPlayerFromCharacter(character), if the player does not exist, the character is not a player character.
it was this easy
local model
if other.Parent:IsA("Model") then
model = other.Parent
end
if not model then return end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.