Okay soooooo I decided to make a poison gas area cloud that would damage people inside it. Here is the script:
debounce = false
local RegionPart = game.Workspace.Gas.GasHitbox
local pos1 = RegionPart.Position - (RegionPart.Size / 2)
local pos2 = RegionPart.Position + (RegionPart.Size / 2)
local region = Region3.new(pos1,pos2)
while true do
wait()
local partsInRegion = workspace:FindPartsInRegion3(region, nil,100)
for i, part in pairs(partsInRegion) do
if part.Parent:findFirstChild("Humanoid") ~= nil and debounce == false then
debounce = true
print("Player found in region!".. part.Parent.Name)
local char = part.Parent
char.Humanoid.Health = char.Humanoid.Health -5
wait (1)
debounce = false
end
end
end
Keep in mind, I put this in server script service and this mostly worked with one player until two of them are in it. Also it kind of lags behind now so the player takes damage even after they leave the area of effect. Help would be much appreciated.
Thanks!
