Hi guys! I have a script that randomly rolls a number 1-5 and and it does an action based on that number. when the number is chosen it fires an event to execute an action. But for one of the actions, I used GetPartsInPart to see if a humanoid is in a box, and if they are, they die. However sometimes it doesnt kill all of the humanoids in the part, despise them being in there.
and here is the code:
if rng == 5 then
local parts = game.Workspace:GetPartsInPart(hitbox)
for i, part in pairs(parts) do
if part.Parent:IsA("Model") then
if part.Parent:FindFirstChild("HumanoidRootPart") and part.Parent.Name ~= script.Parent:FindFirstChildWhichIsA("IntValue").Name then
local player = game.Players:FindFirstChild(hitbox:FindFirstChildWhichIsA("IntValue").Name)
local tagval = part.Parent:FindFirstChildWhichIsA("IntValue")
tagval.Name = player.Name
print(part.Name)
part.Parent:FindFirstChild("Humanoid").Health = 0
end
end
end
end