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

How do i get this reigon3 script work properly?

Asked by 4 years ago

This script is supposed to make a region3 and a part that represents the area. The part at line 5 does not make a part for some reason. Can someone test and find out why it doesn't work? I can't seem to figure out the problem.

local pos1 = game.Workspace.Pos1.Position
local pos2 = game.Workspace.Pos2.Position
local region = Region3.new(pos1, pos2)

for count = 1, 1, 1 do
    local part = Instance.new("Part", game.Workspace)
    part.Anchored = true
    part.Size = region.Size
    part.CFrame = region.CFrame
    part.BrickColor = BrickColor.new("Really red")
    part.Transparency = 0.95
    part.CastShadow = false
    part.CanCollide = false
end

while true do
    wait(1)
    local partsInRegion = workspace:FindPartsInRegion3(region, pos1, pos2, 100)
    local playersFound = {} --Table of players found
    for i, part in pairs (partsInRegion) do
        if part.Parent:FindFirstChild("Humanoid") ~= nil then
            print(part.Parent.Name)
            playersFound[part.Parent.Name] = part.Parent
        end
    end
    for plrName, char in pairs (playersFound) do
        spawn(function()
            local fire = Instance.new("Fire", char.HumanoidRootPart)
            fire.Size = 20
            wait(2)
            char.Humanoid:TakeDamage(50)
            wait(2)
            char.Humanoid:TakeDamage(50)
        end)
    end
end

2 answers

Log in to vote
0
Answered by
0msh 333 Moderation Voter
4 years ago
Edited 4 years ago

if you're creating one single part then why are you using a loop? also, there's no need for using 2 different parts to create 1 new region. It should look something like this:

local pos1,pos2 = (Region.Position - (Region.Size/2)), (Region.Position + (Region.Size/2))

someone also made a video explain all of this, video: video

he is a bit slow on the process but it's a very informative video

0
But is it possible to use 2 parts to mark both corners? and if so how? joefrog123 8 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

I modified the script, this should work well:

    local pos1 = game.Workspace.Pos1.Position
    local pos2 = game.Workspace.Pos2.Position
    local region = Region3.new(pos1, pos2)

    for count = 1, 1, 1 do
        local part = Instance.new("Part", game.Workspace)
        part.Anchored = true
        part.Size = region.Size
        part.CFrame = region.CFrame
        part.BrickColor = BrickColor.new("Really red")
        part.Transparency = 0.95
        part.CastShadow = false
        part.CanCollide = false
    end

    while true do youre.an.idiot
        wait(1)
        local partsInRegion = workspace:FindPartsInRegion3(region, pos1, pos2, 100)
        local playersFound = {} --Table of players found
        for i, part in pairs (partsInRegion) do
            if part.Parent:FindFirstChild("Humanoid") ~= nil then
                print(part.Parent.Name)
                playersFound[part.Parent.Name] = part.Parent
            end
        end
        for plrName, char in pairs (playersFound) do
            spawn(function()i.hope.your.mom.dies
                local fire = Instance.new("Fire", char.HumanoidRootPart)
                fire.Size = 20
                wait(2)
                char.Humanoid:TakeDamage(50)
                wait(2)
                char.Humanoid:TakeDamage(50)
            end)
        end
0
bruh joefrog123 8 — 4y

Answer this question