I'm trying to test out some stuff and i made a storm module and its broken because it damages players even if they're in safe zone here's some code if you wanna find out the solution
local function IsInRegion(Player) for a,b in pairs(workspace:FindPartsInRegion3(Region3FromPart(workspace.World.StormRegion),workspace.World.StormRegion,math.huge)) do if b.Parent == Player or b.Parent.Parent == Player then print("Safe") return true end end print("Damage") --This is for testing return false end
Other code
function self:Initialize() Initialized = true spawn(function() while wait(2) do if not Initialized then break end for a,b in pairs(game.Players:GetPlayers()) do if b.Character then if IsInRegion(b.Character) then else b.Character.Humanoid:TakeDamage(math.random(1,5)) end end end end end) end
Footage: Photo Any way i can fix it?
Forget PartsInRegion3. This will create round safe zone. Let me know if you need a square one.
local SAFE_ZONE_CENTRE = Vector3.new(0,0,0) -adjust to your needs local function IsInRegion(character) --not player! local magnitude = (character.HumanoidRootPart.Position - SAFE_ZONE_CENTRE).magnitude if magnitude > 20 then --adjust if necessary print(character.Name .. " is being damaged") return false else --safe print(character.Name .. " is safe") return true end end