Announce on Specific Area covered by a Perimeter

Hi there everyone, hope I can get the right help with this one.

I’m having troubles how I’ll start moving a step above this coding because I got code-blocked… I don’t know how to detect players that are already in this area receive only the announcement :sob:

		local HumanoidRootPart = player.Character:WaitForChild("HumanoidRootPart")
		
		local newInstance = Instance.new("Part")
		local Weld = Instance.new("Weld")
		newInstance.Parent = HumanoidRootPart
		Weld.Parent = newInstance
		Weld.Part0 = newInstance
		Weld.Part1 = HumanoidRootPart
		
		newInstance.Transparency = 1
		newInstance.Anchored = false
		newInstance.CanCollide = false
		
		TweenService:Create(newInstance, Info, {Size = Vector3.new(100,100,100)}):Play()
		
		
		wait(5)
		newInstance:Destroy()

this script creates a Block that expands in the Player’s HumanoidRootPart that announced it. And I got lost at this part on how that new Instance will detect players inside of it to send the announcement…

I actually did the .Touched event, idk if that would work? I’ll try this out in a bit.

	elseif announcetype == "2" then
		local HumanoidRootPart = player.Character:WaitForChild("HumanoidRootPart")
		
		local newInstance = Instance.new("Part")
		local Weld = Instance.new("Weld")
		newInstance.Name = "AnnounceBlock"
		newInstance.Parent = HumanoidRootPart
		Weld.Parent = newInstance
		Weld.Part0 = newInstance
		Weld.Part1 = HumanoidRootPart
		
		newInstance.Transparency = 1
		newInstance.Anchored = false
		newInstance.CanCollide = false
		
		TweenService:Create(newInstance, Info, {Size = Vector3.new(100,100,100)}):Play()
		
		local Clone_1		= Frame_1:Clone()
		local Clone	 		= Clone_1:WaitForChild("Announcement")
		local ImageLabel 	= Clone.Image
		Clone_1.Parent		= MainFrame
		Clone_1.Visible		= true
		
		local Message 	= Clone.Message
		local PlayerN	= Clone.PlayerRecip
		local cd			= Clone.Time
		
		PlayerN.Text = playerRPName.." Announced: "
		Message.Text = filter

		game.Workspace:FindFirstChild("AnnounceBlock").Touched:Connect(function()
			TweenService:Create(Clone, Info, {Position = UDim2.fromScale(0, 0)}):Play()
			TweenService:Create(Clone, Info, {Size = UDim2.fromScale(1, 1)}):Play()
			TweenService:Create(ImageLabel, Info, {ImageTransparency = 0}):Play()
			Sound:Play()
			repeat
				cd.Text = Timer
				wait(1)
				Timer -= 1
			until Timer <= 0
			cd.Text = "0"
			wait(Timer)
			TweenService:Create(Clone, Info2, {Position = UDim2.fromScale(0.5, 0.5)}):Play()
			TweenService:Create(Clone, Info2, {Size = UDim2.fromScale(0, 0)}):Play()
			TweenService:Create(ImageLabel, Info2, {ImageTransparency = 1}):Play()

			wait(1.5)
			Clone_1:Destroy()
		end)	
		
		wait(1)
		newInstance:Destroy()

okay apparently, the touched event isn’t working… What is it called that detects players inside it?? I forgot… can someone help me out. Was it renderstepped?

Try using the ZonePlus Module, might seem really hard to use.. but.. trust me it’s really not, it’s a module..

2 Likes

ooo thanks! Let me give this a try and I’ll get back with ya’ll and see if this solves my problem

1 Like

like @PinkPainted said, zoneplus would help you. However if you were to make this without, you should look into Region3
This Post Should help you out.

1 Like

okay both of these options sounds great to know, I’ll make sure to dive right into ZonePlus for a bit. The whole thing is a bit confusing lol

Just make sure you look into the document if there is one. If not you can always see a youtube video

1 Like

@iiNathxnism Region3 is Deprecated. Use GetPartsInPart() instead

1 Like

I’m using ZonePlus right now and I’m getting around with it, got stuck with this one lol
image

this is what I did:

		local HumanoidRootPart = player.Character:WaitForChild("HumanoidRootPart")
		
		local newInstance = Instance.new("Part")
		local Weld = Instance.new("Weld")
		newInstance.Name = "AnnounceBlock"
		newInstance.Parent = HumanoidRootPart
		Weld.Parent = newInstance
		Weld.Part0 = newInstance
		Weld.Part1 = HumanoidRootPart
		
		newInstance.Transparency = 0.9
		newInstance.Anchored = false
		newInstance.CanCollide = false
		
		TweenService:Create(newInstance, Info, {Size = Vector3.new(50,50,50)}):Play()
		
		local Clone_1		= Frame_1:Clone()
		local Clone	 		= Clone_1:WaitForChild("Announcement")
		local ImageLabel 	= Clone.Image
		Clone_1.Parent		= MainFrame
		Clone_1.Visible		= true
		
		local Message 	= Clone.Message
		local PlayerN	= Clone.PlayerRecip
		local cd			= Clone.Time
		
		PlayerN.Text = playerRPName.." Announced: "
		Message.Text = filter
		
		local newZone = Zone.new(newInstance)
		local getplayersinZone = newZone:getPlayers()
		getplayersinZone(function(player: plr) -- this is Line 64
			print("players Detected in Zone.")
			TweenService:Create(Clone, Info, {Position = UDim2.fromScale(0, 0)}):Play()
			TweenService:Create(Clone, Info, {Size = UDim2.fromScale(1, 1)}):Play()
			TweenService:Create(ImageLabel, Info, {ImageTransparency = 0}):Play()
			Sound:Play()
			repeat
				cd.Text = Timer
				wait(1)
				Timer -= 1
			until Timer <= 0
			cd.Text = "0"
			wait(Timer)
			TweenService:Create(Clone, Info2, {Position = UDim2.fromScale(0.5, 0.5)}):Play()
			TweenService:Create(Clone, Info2, {Size = UDim2.fromScale(0, 0)}):Play()
			TweenService:Create(ImageLabel, Info2, {ImageTransparency = 1}):Play()

			wait(1.5)
			Clone_1:Destroy()
		end)			
		wait(1)
		newInstance:Destroy()

was the whole code too fast?

Get players in zone returns a table with the players in it. Its not a function.

1 Like

Is it? It does not say that in the document

Region3 itself isn’t deprecated, but WorldRoot:FindPartsInRegion3() is.

1 Like

oh mb… I felt dumb after doing that… tho- should I use the Event PlayerEntered in the ZonePlus Module? or is there a different way of detecting for the code to go through?

Yea use the PlayerEntered event, that would be very efficient.

But what if for players that are already inside the perimeter? Won’t they get the announcement since they didn’t stepped on the covered space?

Is the player spawning in the part? Is the part spawning where the player is? Im not sure if the zone module sends the event when it spawns and detects the player. But you shouldnt worry about it if the player doesnt spawn in it or the part doesnt spawn on the the player. In such cases you should either do a loop checking the player entered array or when you spawn it in you check if there are players in and if not then continue as intended. (For optimization, you should make it event wise and not loops. Since that would take memory, making your script slower)

Tl;dr if the player isnt spawning in the part or the other way around, youre good.

1 Like

its spawning it, but its returning nil
image

what I did is this:

		local newZone = ZonePlus.new(newInstance) -- this creates a new part inside the HumanoidRootPart of the Player that sent the announcement
		
		newZone.PlayerEntered:Connect(function(player: plr) -- this is the Line 65
			print("players in zone, Sending Announcement.")
			TweenService:Create(Clone, Info, {Position = UDim2.fromScale(0, 0)}):Play()
			TweenService:Create(Clone, Info, {Size = UDim2.fromScale(1, 1)}):Play()
			TweenService:Create(ImageLabel, Info, {ImageTransparency = 0}):Play()
			Sound:Play()
			repeat
				cd.Text = Timer
				wait(1)
				Timer -= 1
			until Timer <= 0
			cd.Text = "0"
			wait(Timer)
			TweenService:Create(Clone, Info2, {Position = UDim2.fromScale(0.5, 0.5)}):Play()
			TweenService:Create(Clone, Info2, {Size = UDim2.fromScale(0, 0)}):Play()
			TweenService:Create(ImageLabel, Info2, {ImageTransparency = 1}):Play()

			wait(1)
			Clone_1:Destroy()			
		end)

yes it creates a block instance before the actual event happens.

Why are you making a zone inside the humanoidroot part? that is so confusing. You should just make 1 big zone.
take a look at this

Also i belive you typed the event wrong, i think its playerEntered, not PlayerEntered. Lua is case sensitive. Use the github document