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.
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.
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.
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)
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