Script Escape from prison

I am creating a game with a prison and I need that when a player from the Prisoners team leaves the territory of the prison, his team should be changed to Criminals. If someone knows how to implement this script, then help pls. I think that it is possible for him to touch the block in which there is a script changing the command, but there is also the Guards command and this should not work on them.

Google helps.

I need this to not work for all teams

Pretty simply, check if the player leaves a certain zone. Either through touching a part or an alternative.
Pseudo(ish) code:

if playerTeam == "Prisoner" then
	if playerZone ~= PrisonZone then
		playerTeam = "Criminal"
	end
end

You can change a player’s team on Roblox like this:

Player.Team = game:GetService("Teams").TeamName
1 Like

What do you mean? Can you please elaborate?

A team change should only work for Prisoners

Check if the player is on the prisoner team then.

local Teams = game:GetService("Teams")
local Prisoners = Teams.Prisoners

if Player.Team == Prisoners then
	--// Do stuff
end

Maybe you could use Region3?

You can try adding this following script to the Part which prisoners will change team when touching it.

local Prisoners = "Prisoners" --Whatever name of the prisoner team is.
local Criminals = "Criminals" --Whatever name the team you want them to switch to
Teams = game:GetService("Teams")
script.Parent.Touched:Connect(function(hit)
  if hit.Parent:FindFirstChildOfClass("Humanoid") then --To check if it is a player
    local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if Player.Team == Teams[Prisoners] then --Check the original team
      Player.Team = Teams[Criminals]  --Changes the player's team
    end
  end
end)

Hope this helps.

3 Likes

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