Ok this is quite advance, I made a region3 script that detects when a player is in the area and how to do I detect when the player has left the area?
local regoin = Region3.new(Vector3.new(1,1,1), Vector3.new(9,9,9)) local part = Instance.new("Part", game.Workspace) part.Anchored = true part.Size = regoin.Size part.CFrame = regoin.CFrame part.CanCollide = false part.Transparency = .5 while true do wait(1) local regionparts = workspace:FindPartsInRegion3(regoin, part, 100) for i, part in pairs(regionparts) do if part.Parent:FindFirstChild("Humanoid") ~= nil then print(part.Parent.name) end end end
local runService = game:GetService("RunService") local regoin = Region3.new(Vector3.new(1,1,1), Vector3.new(9,9,9)) local part = Instance.new("Part") part.Parent = workspace part.Anchored = true part.Size = regoin.Size part.CFrame = regoin.CFrame part.CanCollide = false part.Transparency = .5 local wasFound = false runService.RenderStepped:Connect(function() local found local regionparts = workspace:FindPartsInRegion3WithWhiteList(regoin, game.Players.LocalPlayer.Character:GetDescendants(), 100) for i, v in next, regionparts do if v:IsDescendantsOf(game.Players.LocalPlayer.Characrer) then found = true wasFound = true break end end if not found and wasFound then print("player left area") wasFound = false end end)
edit: formatting