What is the issue? so, when my hitbox touch a enemy he is added to a table just one time, which is the normal, however, if the hitbox touch 2 enemies for example, they are added 2 times in the table, and i want them to be added only once, not two, because i think this is causing some weird bugs in my game. I think the answer to this should be easy, so I won’t provide any code.
Could you share your code that connects to the Touched events and how it adds the values to your table? We can only take wild guesses at what might be wrong without seeing the code; it could be redundant connections, lack of checking if something’s already in the table, naive handling of Touched events (they fire continuously during part overlaps), etc.
Sorry, I’m new here and thought it wouldn’t be necessary to include the script. I would send it now, but it’s 10 PM here, and I’ll only be able to send it tomorrow. Thanks for the heads-up!
1 Like
local Part = workspace.Part1 -- Example
local MyTable = {}
Part.Touched:Connect(function(Hit)
local Model = Hit:FindFirstAncestorOfClass("Model")
if Model then
if table.find(MyTable, Model) == nil then
table.insert(MyTable, Model)
end
end
end)
just use table.find in an if statement to see if somethings already in the table