How do you make a system that alects the criminal when the police enters the building?

  1. What do you want to achieve? Trying to make a alect that sends to the criminal robbing the bank when a police enters the building like Jailbreak.

  2. What is the issue? The Issue is I don’t know how that even works.

  3. What solutions have you tried so far? There’s not a solution for this.

I just want a system that alects the criminals when the police enters the building like jailbreak

1 Like

I would suggest making a Invs part and when a player touches it. The function checks if it’s a cop and if yes alerts the bad criminals

2 Likes

To make a trigger that alerts players when someone of a certain team enters a building, make a script with the following steps:

  1. Touched event in invisible part spanning length and width of door or gateway.
  2. Check the player’s team, if police then fire a remoteevent to all clients.
  3. Upon picking the remote event up on the client, use StarterGui:SetCore(action) to create a notification for the player. The method you’ll want is called SendNotification.
  4. Fill out parameters and done! :0

Would make this neater and more clear but on phone and just cba.

Important: You must always perform SetCore actions on the client or else they won’t work!!

4 Likes

You would want to create a part, add a remote into replicatedstorage, and create a touched function. You’re also going to need to insert stringvalues inside of the players. And you will also need a LocalScript to create the function that runs when this script fires.

local brick = script.Parent
local notification = game.ReplicatedStorage:WaitForChild("NotifierEvent")

function scanForCriminal(Player, Area)
	for _,criminal in pairs(game.Players:GetPlayers()) do
		local PlayersLocation = criminal:FindFirstChild("Area")
		if PlayersLocation.Value ~= Area then
			
		else
			if criminal:FindFirstChild("Role") and criminal.Role.Value == "Criminal" then
				notification:FireClient(Player, criminal)
			end
		end
	end
end

brick.Touched:Connect(function(Hit)
	if game.Players:GetPlayerFromCharacter(Hit.Parent) then
		local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
		if Player:FindFirstChild("Role") and Player.Role.Value == "Cop" then
			local BrickArea = script.Parent.Name
			if Player:FindFirstChild("Area") then
				local PlayersLocation = Player:FindFirstChild("Area")
				if PlayersLocation.Value ~= BrickArea then
					PlayersLocation.Value = BrickArea
					scanForCriminal(Player, BrickArea)
				end
			end
		end
	end
end)
1 Like

Wait how do I fire all clients? Don’t I have to put the player arguments?

The script above uses ‘FireClient’ with the arguments Player, and criminal. In your local script you can create an event that detects when the specific player’s client has been called.

You simply make a variable locating the remote event, and use ‘OnClientEvent’ as an event to connect the function. After that you just need to add the criminal argument inside of that function because since your script is local you can get the player either way.

e.g

local Remote = game.ReplicatedStorage:WaitForChild("NotifierEvent")
local Player = game.Players.LocalPlayer
Remote.OnClientEvent:Connect(function(criminal)
-- do stuff here
end)

You can change the script above the part that says ‘FireClient(Player, criminal’ to ‘FireAllClients(criminal)’, if that’s what you meant.

SERVER
RemoteEvent:FireAllClients()
CLIENT
RemoteEvent.OnClientEvent:Connect(function()
end)

1 Like

So I don’t need play arguments on the server script?

No, FireAllClients() fires to each client in game.

Essentially, think of it as a pairs loop of all the players in the game and doing FireClient()

On the client, just reference the player as LocalPlayer as it doesn’t matter. Format your arguments you want to pass through such as the criminal’s name to display and the building they entered.

E.g.

-- Server
Event:FireAllClients(criminal, building)

-- Client
Event.OnClientEvent:Connect(function(player, criminal, building)