I only take damage when I’m near the region Corner…
Video:
robloxapp-20210227-1154597.wmv (1.3 MB)
Code:
local region = Region3.new(Vector3.new(5,0,5), Vector3.new(15,15,15)) -- Making Our Region
local newPart = Instance.new("Part") -- Making A Part
newPart.Anchored = true
newPart.Size = region.Size
newPart.CanCollide = false
newPart.Transparency = 0.5
newPart.Parent = game.Workspace
while true do
wait()
local partsInRegion = game.Workspace:FindPartsInRegion3(region, newPart, 1000) --[[Finding all the things
inside our region(part). It also returns a table
--]]
for _,object in pairs(partsInRegion) do -- Looping through the table
local hum = object.Parent:FindFirstChild("Humanoid")
if hum ~= nil then -- If the object inside the region is a player then
hum.Health -= 5 -- Take 10 hp from the player
end
end
end