Hello everyone,
It’s been several weeks that I’m struggling to solve a problem with a system for my Obby.
Here is my last topic (Problem with TouchedEvent when the character don't move - #5 by valtkins) concretely I have a system that activates and deactivates every X seconds, so if the player is already in the zone where the .Touched event is launched then it does not activate (if the player does not move).
I’m trying to get the same result but without the region3 issue.
The only problem is that to check with a region3 it is necessary to use a while loop but I use it so I cannot integrate it at the same time as the region3.
Here are the “contrainters” and “rules” to create a script to help me…
-There are 2 groups, each containing 2 parts.
-When the player touches a zone he dies.
-Group 1 and 2 are activated in a staggered way (e.g. when group 1 works, group 2 has no effect)
-With these parts we will create a region3.
-The activation of the zones changes every 5 seconds
Hierarchy of the parts:
Image of the parts (Yellow is groups 1 and red is groups 2):
Current script, i tryed to rewrite it like 5 times, but every times i get blocked with the region3 (for checking the player in the zone):
print("Iniatialization...")
local objectFolder = game.Workspace.Region3
local group1 = {}
local group2 = {}
local region3Zones_fans1_region = {}
local region3Zones_fans1_reference = {}
local region3Zones_fans2_region = {}
local region3Zones_fans2_reference = {}
local resultOfRegion3 = {}
local function effect()
print("Touched") --or kill player
end
for k, v in pairs(objectFolder:GetChildren()) do
if v.Name == "Groups1" then
table.insert(group1,#group1+1,v)
elseif v.Name == "Groups2" then
table.insert(group2,#group2+1,v)
end
end
for k, v in pairs(group1) do
local reference = v
local minRegion3 = reference.Position - (0.5 * reference.Size)
local maxRegion3 = reference.Position + (0.5 * reference.Size)
local region3 = Region3.new(minRegion3,maxRegion3)
table.insert(region3Zones_fans1_region,#region3Zones_fans1_region + 1, region3)
table.insert(region3Zones_fans1_reference,#region3Zones_fans1_reference + 1, reference)
end
for k, v in pairs(group2) do
local reference = v
local minRegion3 = reference.Position - (0.5 * reference.Size)
local maxRegion3 = reference.Position + (0.5 * reference.Size)
local region3 = Region3.new(minRegion3,maxRegion3)
table.insert(region3Zones_fans2_region,#region3Zones_fans2_region + 1, region3)
table.insert(region3Zones_fans2_reference,#region3Zones_fans2_reference + 1, reference)
end
wait(10)
print("Finished")
while true do
resultOfRegion3 = workspace:FindPartsInRegion3WithIgnoreList(currRegion, {currReference}, math.huge)
wait()
end
My problem is to use the while true loop, to check the results of region3, while I also use it to activate and deactivate my groups.
Huge Thanks.