Still have questions? Join our Discord server and get real time help.
Log in to vote

How to Position Region3 in front of the player?

Asked by 4 days ago

I just started learning about region 3, and I want to make a region that appears in front of the player when he presses a key. The problem is that the region3 always get in the same direction no matter how I move the player. can someone help me settle it please??

Here is the script,

local c = plr.Character

    local Reg =,2.5,2.5),c.HumanoidRootPart.Position,2.5,2.5))

    local Part ="Part",workspace)
    Part.CFrame = Reg.CFrame
    Part.Size = Reg.Size
    Part.Anchored = true
    Part.CanCollide = false
    Part.Transparency = 0.8

    local Rtable = workspace:FindPartsInRegion3(Reg,c)

    for i,v in pairs(Rtable) do
        if v.Parent:findFirstChild('Humanoid') and v.Parent.ClassName == 'Model' and v.Parent:findFirstChild('AoEDebounce')== nil then
            local Deb ='BoolValue',v.Parent)
            local BV ="BodyVelocity",v)
            BV.MaxForce =,25000,25000)
            BV.Velocity = c.HumanoidRootPart.CFrame.LookVector * 50
            Deb.Name = 'AoEDebounce'

3 answers

Log in to vote
Answered by 4 days ago
Edited 4 days ago

This is because you gave constant vectors (vectors that always stay the same) to specify a direction in your Region3 arguments. You must base it off vectors that will be based off the player's direction, namely the unit vectors which you have used one (CFrame.LookVector).

By using CFrame, it will be as simple as changing your Reg variable to this although I will add a CFrame variable and number variable to make the Reg variable simpler and shorter to read:

local cf = c.HumanoidRootPart.CFrame
local Z_multiplier = c.HumanoidRootPart.Size.Z/2 -- becomes negative later because -Z is forward, by multiplying position Z by this, you will reach the front surface of the object
local Reg = *,2.5, -(Z_multiplier + 2.5) ), cf *,2.5, Z_multiplier + -(Z_multiplier + 2.5) ))

You might need to adjust the CFrame coordinates for X or Y if the result is still undesirable.

I tried your idea but it still doesn't work. It say: invalid argument #1 to 'new' (Vector3 expected,got CFrame) SaitamaSaan 9 — 3d
Log in to vote
Answered by 3 days ago

If only it was about CFrame, but, in region3 you can only use Position / Vector3 :( . I tried your idea but it still doesn't work. It say: invalid argument #1 to 'new' (Vector3 expected, got CFrame)

Log in to vote
Answered by
A_thruZ 29
2 days ago

Try using @ArtFoundation's answer and use CFrame.Position wherever you are currently using CFrame.

Answer this question