I’m genuinely embarrassed of how much I’m using the forum for help but my region3 script isn’t working and I’m trying to make it if you are in the region you die but I’m having trouble with that here is the script,
local workspace = game:GetService("Workspace")
local box = Instance.new("Part")
box.Position = Vector3.new(98.874, 7.5, 213.481)
box.Anchored = true
box.Size = Vector3.new(15,15,15)
box.CanCollide = false
box.Transparency = 0.9
box.Parent = workspace
local region = Region3.new(box.Position - box.Size / 2, box.Position + box.Size / 2)
while true do
task.wait()
local partsInRegion = workspace:FindPartsInRegion3(region, box, 1000)
local found = {}
for i, part in pairs(partsInRegion) do
local player = players:GetPlayerFromCharacter(part.Parent)
if player and not table.find(found, player) then
table.insert(found, player)
print("player found in the region!: " .. player.Name)
part.Parent:FindFirstChild("Humanoid")
local char = box.Parent
char.Humanoid:TakeDamage(char.Humanoid.MaxHealth)
end
end
end```
it’s a little buggy, but i’m sure you’ll be able to fix it with a cooldown.
local workspace = game:GetService("Workspace")
local box = Instance.new("Part")
box.Position = Vector3.new(98.874, 7.5, 213.481)
box.Anchored = true
box.Size = Vector3.new(15, 15, 15)
box.CanCollide = false
box.Transparency = 0.9
box.Parent = workspace
local region = Region3.new(box.Position - box.Size / 2, box.Position + box.Size / 2)
while true do
task.wait()
local partsInRegion = workspace:FindPartsInRegion3(region, box, 1000)
local found = {}
for i, part in pairs(partsInRegion) do
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player and not table.find(found, player) then
table.insert(found, player)
print("player found in the region!: " .. player.Name)
part.Parent:FindFirstChild("Humanoid")
local char = player.Character
char.Humanoid:TakeDamage(char.Humanoid.MaxHealth)
end
end
end
I know, but it doesn’t necessarily means it completely stopped working, its backends are no longer being improved or updated, but still works but it is discouraged to use so.
So to top it off i have a weird obsession of using RunService over Region3. Anyways, here’s the script which i hope will help you!
local Hit = false
local Timer = 0 -- not required
local Connection;
local Humanoid;
local RegionLifetime = 200 -- not required and you can change the value
Connection = game:GetService(“RunService”).RenderStepped:connect(function() -- use Heartbeat if it’s a server script
if Hit == false then
Timer = Timer + 0.1
if Timer >= RegionLifeTime then
Hit = true Connection:Disconnect()
end
local Region = Region3.new(your part’s region info here)
for i, v in pairs(game.Workspace:FindPartsInRegion3(Region, Ignorelist, MaxParts)) do
if v and v.Parent and v.Parent:FindFirstChild(“Torso”) and v.Parent:FindFirstChild(“HumanoidRootPart”) then
Humanoid = v.Parent:FindFirstChild(“Humanoid”)
end
if Humanoid and Hit == false then
-- your code here
end
end
end
end)