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

What's the best way to trigger an event when a region3 is touched?

Asked by
Jexpler 63
5 years ago

I have this script:

local ftbR = Region3.new(script.Parent.R1.Position,script.Parent.R2.Position)

while true do
    wait()
    local pir = game.Workspace:FindPartsInRegion3(ftbR, game.Workspace.Baseplate, 1000)
    for i,v in pairs(pir) do
        if v.Parent:FindFirstChild("Humanoid") and v.Name == "Torso" then
            v.Parent.HumanoidRootPart.CFrame = v.Parent.HumanoidRootPart.CFrame * CFrame.new(0,0,108)
        end
    end
end

It's really choppy, and I think it's because it only check every millisecond. Is there a way to trigger it when touched, rather than constantly checking if it's touched?

0
while wait() do ahjdsahdashkdas Warfaresh0t 414 — 5y
0
That's what I don't want. I don't want a loop. Jexpler 63 — 5y

Answer this question