Region3 help youknow how when you enter the region you make something happen how do you make something happen when you exit?

So this may seem simple but I cant figure it out so you know you can make something happen while they are in the region how do you make it so when you exit something happens. For example game the iconic fencing game on Roblox when you enter you can do damage to others when you exit you cant.

local region  = Region3.new(Vector3.new(1,1,1), Vector3.new(10,10,10))

local part  =Instance.new("Part", game.Workspace)
part.Anchored =  true
part.Size = region.Size
part.CFrame = region.CFrame
part.CanCollide = false
part.Transparency = 0.6
part.Color = Color3.new(1, 0, 0)
while true do  
	wait(1)
	local partsInRegion =  workspace:FindPartsInRegion3(region, part, 1000)
	for i, v in pairs(partsInRegion) do
		if v.Parent:FindFirstChild("Humanoid") then
			print("Player in region", v.Parent)
			game.ReplicatedStorage.ClassicSword.Parent = game.StarterPack
		end
	end
end

BTW I’m making sword go to replicated storage when exited region3.

1 Like

I would recommend using ZonePlus for this, it’s pretty simple.

local Zone = require(script.Zone)
local myZone = Zone.fromRegion(CFrame.new(), Vector3.new(20, 20, 20))

myZone.playerEntered:Connect(function(player)
	print(player.Name.." entered the region")
end)

myZone.playerExited:Connect(function(player)
	print(player.Name.." left the region")
end)
1 Like

Same, but I would recommend people trying to help the OP’s main issue here, that is trying to help them solving the problems in their script so that they can get a better gist of how the general idea works.

i am busy now so i cant really help much currently.

1 Like

Took me a while to understand Zone Plus but it worked! Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.