Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

The region is acting weird when it created?

Asked by 4 years ago
Edited 4 years ago

Hi, I was practicing creating Region3. The issue here is that when the region created, its field is weird. The green plate is the field

https://cdn.discordapp.com/attachments/590443236703862795/691539256103010324/image.png

Also, I am trying to make that when the player gets into it take damage but even that doesn’t work. :confused:

Here is the script:

local tweening = game:GetService("TweenService")

local point1 = Instance.new("Part", workspace)
point1.Name = "point1"
point1.Anchored = true
point1.Transparency = 1
point1.Size = Vector3.new(1, 1 ,1)
point1.Position = Vector3.new(-90, 60.037, -32.5)
point1.CanCollide = false

local point2 = Instance.new("Part", workspace)
point2.Name = "point2"
point2.Anchored = true
point2.Transparency = 1
point2.Size = Vector3.new(1, 1 ,1)
point2.Position = Vector3.new(-66.5, 34.037, -2)
point1.CanCollide = false

local myregion = Region3.new(point1.Position, point2.Position)

local partforregion = Instance.new("Part", workspace)
partforregion.CanCollide = false
partforregion.Anchored = true
partforregion.Material = Enum.Material.ForceField
partforregion.BrickColor = BrickColor.new("Lime green")
partforregion.Transparency = 0
partforregion.Size = myregion.Size
partforregion.CFrame = myregion.CFrame

local ignoredParts = {point1,point2,partforregion}

while wait(1) do
    local usedpartsforregion = workspace:FindPartsInRegion3WithIgnoreList(myregion, ignoredParts, math.huge)
    for i, object in ipairs(usedpartsforregion) do
        if object.Parent:FindFirstChild("Humanoid") ~= nil then
            local char = object.Parent
            char.Humanoid:TakeDamage(5)
        end
    end
end

Answer this question