How do I make a arrest gui show on escape?

You can write your topic however you want, but you need to answer these questions:

  1. What am I trying to achieve? Trying to make a arrest gui show for police to arrect criminals.

  2. The issue is that the arrest gui doesn’t show for police.

  3. There is not a solution on the form. I have try some things. I have never did a police system in my prison game so I don’t know much on a fix.

So how do I clone a gui to a player Upper Torso when they escape and also explain how it works.

2 Likes

The first thing I recommend doing is creating an ‘arrested’ BillboardGui. You’ll need a BillboardGui and a TextLabel for that.
When you’re happy with your Arrested BillboardGui, move it to ServerStorage.

When a player is arrested, fetch the BillboardGui from a server-sided script.
Then, use :Clone() to create a new instance of it and set that instance’s parent to the UpperTorso of the arrested player.
All in all, that’ll look like this:

local NewArrestedUI = game:GetService("ServerStorage"):WaitForChild("(... your UI ...)"):Clone()
NewArrestedUI.Parent = -- The character's UpperTorso.
2 Likes

Is it a good idea to use remote events to clone the gui when the player escapes prison?

Ok I did that now what do next?

When a player escapes prison, you should use server script to check whether or not a player is in prison. Then you should clone all necessary GUIs from ServerStorage into the character with the server script, so a RemoteEvent isn’t needed in that case.

So Could I just check if the play is on the criminal team?

That would make your life sooo much easier

Yes. Surround the prison with invisible walls the player cannot collide with. Then make a check on the server side when a prisoner touches the wall, change the team to criminal.

There should be another script that clones all necessary GUIs into every criminal’s character.

1 Like

That part is already coded. So they do be criminal when they escape.

So how would I code the arrect gui for police to arrest criminals? Explain how it works.

Then it’s just a simple server script that clones all GUIs into every criminal’s character.

local Teams = game:GetService("Teams")

local criminalTeam = Teams.Criminal -- Change to your team
local gui = script.Parent.Gui -- Change to your GUI

local connections = {}

function CriminalCharacterAdded(character)
	local upperTorso = character:WaitForChild("UpperTorso")
		
	local clonedGui = gui:Clone()
	clonedGui.Parent = upperTorso
end

criminalTeam.PlayerAdded:Connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait()
	
	CriminalCharacterAdded(character)
	connections[player.Name] = player.CharacterAdded:Connect(function(playerCharacter)
		CriminalCharacterAdded(playerCharacter)
	end)
end)

criminalTeam.PlayerRemoved:Connect(function(player)
	if connections[player.Name] ~= nil then
		connections[player.Name]:Disconnect()
	end
end)
2 Likes

Cool better then what my code is. Thanks!

1 Like

But how do I make it to where you hold e to arrest criminal as police then destroy gui?

But how do I make it to where you hold e to arrest criminal as police then destroy gui?

In the arrest script (it must be server script), find the gui from the upper torso of the criminal and destroy it. Something like this should work in your arrest server script:

-- when arrested:
local upperTorso = criminalCharacter:WaitForChild("UpperTorso")
local arrestGui = upperTorso:FindFirstChild("(YOUR GUI NAME HERE)")

if arrestGui ~= nil then
	arrestGui:Destroy()
end
1 Like

The thing is I haven’t scripted arrest script.

Then script it and add something like that to it in like “when criminal gets arrested” function.

1 Like

Do I have to use a remote event? So I can change the team to prisoner on reset?

So do I have to use userinputservice to arrect or getmouse?

I would highly highly recommend ContextActionService and bind E to arrest action using ContextActionService:BindAction because UserInputService triggers for example when you are chatting.

1 Like