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

How do I make a Region3 trigger each time a specfic object enters?

Asked by 5 years ago
Edited 5 years ago

I've been tinkering around with Region and making locations text pop up on the screen here is my code

local RegPart = game.Workspace.Regionpart
local pos1 = RegPart.Position - (RegPart.Size / 2)
local pos2 = RegPart.Position + (RegPart.Size / 2)
local region = Region3.new(pos1, pos2)
local plr = game.Players.LocalPlayer
local toggle = false
local Wilderness = false
while wait() do
    local partsinregion = workspace:FindPartsInRegion3(region, RegPart, 1000)
    for i,part in pairs(partsinregion) do
        if part.Parent.Name == plr.Name and toggle and Wilderness then
            Wilderness = true
            toggle = true
            print(toggle)
            local plr = game.Players.LocalPlayer
    local Tween = game:GetService('TweenService')
    local Text = script.Parent
    local Info  = TweenInfo.new(
        3,
        Enum.EasingStyle.Sine,
        Enum.EasingDirection.Out,
        0,
        true,
        1
)
local Goals = {
    TextTransparency = 0;
}

local starttween = Tween:Create(Text,Info,Goals)
starttween:Play()
        else
            toggle = false
            Wilderness = false
        end 
    end
end

Answer this question