When I use the handcuffs on a player it doesn't stop doing LoadCharacter. Here is the script:

prisoners = {} --table of people confined to the JailPart
duration = 10 --how many seconds they're cuffed for
gui = script.Timer

function jailTime(prisoner,character)
			if prisoners[prisoner.Name] then
				wait()
			for i, m in pairs(prisoner.Backpack:GetChildren()) do
				m:Destroy()
			end
			for i, m in pairs(character:GetChildren()) do
				if m:IsA("Tool") then
					m:Destroy()
				end
				prisoner.TeamColor = BrickColor.new("Lapis")
			        prisoner:LoadCharacter()
			end
			
			newGui = gui:Clone()
			newGui.Parent = prisoner.PlayerGui
			newGui.Count.Disabled = false
			end
		end
script.AddPrisoner.Event:connect(function(prisoner)
	if not prisoners[prisoner.Name] then
		prisoners[prisoner.Name] = true
		jailTime(prisoner,prisoner.Character)
	else
		prisoners[prisoner.Name]=nil
		prisoners:LoadCharacter()
		
	end
	wait(duration)
	prisoners[prisoner.Name] = false
	prisoner.TeamColor = BrickColor.new("Maroon")
	prisoner:LoadCharacter()
end)

game.Players.PlayerAdded:connect(function(plr)
	 plr.CharacterAdded:connect(function(char)
		jailTime(plr,char)
	end)	
end)

Please help me fix the problem.

3 comments

0

Do you get any errors?

0

It shows a lot of errors but none of them seem to be for this