Hey everyone! I have a little bit of an issue here.
So to get straight, I have this script where it gets anything within the Region3 and make sure it’s a humanoid, put it in a table for a debounce, then damages it.
The problem occurs where we get the humanoids. The script attempts to get the same humanoid and object multiple time despite the debounce the script has.
local regionpart = game.ServerStorage.Range:Clone()
regionpart.Parent = workspace
regionpart.Position = h.Position
local region = Region3.new(regionpart.Position - (0.5 * regionpart.Size),regionpart.Position + (0.5 * regionpart.Size))
local pir = workspace:FindPartsInRegion3(region,nil,math.huge)
local humands = {}
local function checktablevar(tab,val)
for _,vv in pairs(tab) do
if vv == val then
print(val.Parent.Name)
print("yes")
return true
end
end
print(val.Parent.Name)
print("no")
return false
end
for _,hums in pairs(pir) do
if hums.Parent:FindFirstChildWhichIsA("Humanoid") then
if not checktablevar(humands,hums) then
table.insert(humands,hums.Parent:FindFirstChildWhichIsA("Humanoid"))
end
end
end
It damages the dummies till death and never prints yes. What do I do?