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

One of two regions with whitelist not working?

Asked by
trecept 367 Moderation Voter
6 years ago
Edited 6 years ago
local Region1 = Region3.new(Vector3.new(-402, -39, -190), Vector3.new(70, 96, 448))
local Region2 = Region3.new(Vector3.new(630, 258, -143), Vector3.new(185, -39, 300))

while wait(1) do
    local Whitelist = {}
    for _,Plr in pairs(game:GetService("Players"):GetPlayers()) do
        if Plr.Character then
            table.insert(Whitelist,Plr.Character)
        end
    end
    local a = game:GetService("Workspace"):FindPartsInRegion3WithWhiteList(Region1, Whitelist, math.huge)
    local b = game:GetService("Workspace"):FindPartsInRegion3WithWhiteList(Region2, Whitelist, math.huge)
    for i,v in pairs(a) do
        print(1)
    end
    for i,v in pairs(b) do
        print(2)
    end
end

I have this script where print(1) changes the player's health to infinite and print(2) changes the player's health to 100 in certain region3s, but only Region1 is working? The player originally spawns in region1 and their health is changed, but when they enter region2 nothing happens? (1 is printed to console but 2 is never printed)

Answer this question