Hi, I'm trying to detect if there is a player that is not in region3, but I don't understand how!
local Region = Region3.new(Vector3.new(258, -47, -99), Vector3.new(348, -23, 99)) local Workspace = game:GetService("Workspace") while wait(1) do local PartsInRegion = Workspace:FindPartsInRegion3(Region) for _,Child in pairs(PartsInRegion) do if Child:IsA("BasePart") then local BasePart = Child if BasePart and BasePart.Parent then if BasePart.Parent:FindFirstChild("Humanoid") then local Character = BasePart.Parent local Humanoid = Character.Humanoid local Players = game:GetService("Players") local Player = Players:GetPlayerFromCharacter(Character) if Player then local BoolValue = Character:WaitForChild("IsFighting") BoolValue.Value = true end end end end end end
Hello Bankrovers,
My name is YelloMynamesZak and I'd be happy to help you with your problem.
You could try this: Make a part that represents the region. After you're done, name it "Region".
Then, put a localscript in StarterCharacterScripts and type the following:
local Touching = false local part = workspace.Region part.Touched:Connect(function() Touching = true print("Player is in region") end) part.TouchEnded:Connect(function() Touching = false print("Player is NOT in region") end)
This’ll work for a local script. If this is a server sided script then you can make a table which has each user’s ID as the index, and the value equal to false. Set it equal to true upon touching the part, then set it to false upon the touch ending. It's much more simpler than the code you provided and can be connected to server scripts via remote events.
Please reply to this answer is you're facing any issues.
Hope this helps!