Making Arrest system

  1. What do you want to achieve? I want to make system when someone puts charges example Evasion it changes the SentanceBox text to time which is listed on the script.

  2. What is the issue? The issue is when you type anything in it it automatically changes the text to 450, also it doesn’t change the time what I want with different charges.
    Here’s the videos: https://gyazo.com/16f71aecfe07ecf501b9808c31f6af2a, https://gyazo.com/3b44f545bdfc632d08bc2602eda1e331

Close

  1. What solutions have you tried so far? I’ve tried removing the "Local JailTimes = {} and changed example script.Parent.Parent.SentenceBox.Text = “450” so it has the text in it, put didn’t work out.
    ¨
    Script:
local JailTimes = {
EvasionCharge = 450;
 TreasonCharge = 1000;
 HighTreasonCharge = 1200;
 RiotCharge = 450;
 PiracyCharge = 450;
 HijackingCharge = 600;
 BombCharge = 500;
 CausingdisturbanceCharge = 100;
 CommonnuisanceCharge = 400;
 BriberyCharge = 500;
 CourtOrder = 500;
 Resisting = 450;
 Personating = 300;
 ObstructingJ = 300;
 Publicmischief = 450;
 Prisonbreach = 600;
Criminalnegligence = 450;
Firstdegreemurder = 600;
Seconddegreemurder = 550;
AttemtedMurder = 550;
Manslaughter = 500;
Criminalharassment = 300;
Utteringthreats = 300;
Assault = 450;
Aggravatedassault = 500;
Kidnapping = 450;	
Dangerousoperation  = 350;
flightcahrge = 600;
FailureStop = 450;
Theft = 350;
MotorTheft = 450;	
Robbery = 450;
Breakingentering = 450;
Trespassing = 400;
Mischief = 350;
Arson = 600;
DischargingFirearm = 500;
Carelessuseofafirearm = 300;
PointingFirearm = 400;
Unauthorizedpossession = 400;
Attempttocommitanoffence = 400;
Solicitationtocommitanoffence = 300;	
Conspiracytocommitanoffence = 300;	
Conspiracytocommitamurder = 450;
Aidingandabetting = 300;
Operatingbusinesswolicense = 350 
}

--script
script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
	if script.Parent.Text == "Flight from a peace officer" or "Evasion" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.EvasionCharge
	elseif script.Parent.Text == "Treason" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.TreasonCharge
    elseif script.Parent.Text == "High Treason" then 
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.RiotCharge	
      elseif script.Parent.Text == "Riot" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.PiracyCharge
    elseif script.Parent.Text == "Piracy"  then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.HijackingCharge
	elseif script.Parent.Text == "Hijacking" then 
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.HijackingCharge
	elseif script.Parent.Text == "Possession of an explosive substance or device" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.BombCharge
	elseif script.Parent.Text == "Causing disturbance" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.CausingdisturbanceCharge
	elseif script.Parent.Text == "Common nuisance" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.CommonnuisanceCharge

	elseif script.Parent.Text == "Bribery of a peace officer or justice" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.BriberyCharge
	elseif script.Parent.Text == "Disobeying an order of court" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.CourtOrder
    elseif script.Parent.Text == "Resisting a peace officer" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Resisting
	elseif script.Parent.Text == "Personating a peace officer" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Personating
	elseif script.Parent.Text == "Perjury" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Perjury
    elseif script.Parent.Text == "Obstructing justice" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.ObstructingJ
    elseif script.Parent.Text == "Public mischief" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Publicmischief
	elseif script.Parent.Text == "Prison breach" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Prisonbreach
    elseif script.Parent.Text == "Criminal negligence" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Criminalnegligence
   elseif script.Parent.Text == "First degree murder" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Firstdegreemurder
	elseif script.Parent.Text == "Second degree murder" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Seconddegreemurder
    elseif script.Parent.Text == "Attempt to commit a murder" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.AttemtedMurder
	elseif script.Parent.Text == "Manslaughter" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Manslaughter
	elseif script.Parent.Text == "Criminal harassment" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Criminalharassment
    elseif script.Parent.Text == "Uttering threats" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Utteringthreats
	elseif script.Parent.Text == "Assault" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Assault
	elseif script.Parent.Text == "Aggravated assault" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Aggravatedassault
	elseif script.Parent.Text == "Kidnapping" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Kidnapping
	elseif script.Parent.Text == "Dangerous operation " then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Dangerousoperation 
	elseif script.Parent.Text == "Flight while endangering the lives of others" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.flightcahrge
	elseif script.Parent.Text == "Failure to stop after an accident" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.FailureStop
	elseif script.Parent.Text == "Theft" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Theft
	elseif script.Parent.Text == "Theft of a motor vehicle or vessel" or "Motor Theft" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.MotorTheft
	elseif script.Parent.Text == "Robbery"  then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Robbery
	elseif script.Parent.Text == "Extortion"  then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Extortion
	elseif script.Parent.Text == "Breaking and entering"  then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Breakingentering
	elseif script.Parent.Text == "Trespassing"  then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Trespassing
	elseif script.Parent.Text == "Mischief"  then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Mischief
	elseif script.Parent.Text == "Arson"  then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Arson
	elseif script.Parent.Text == "Discharging a firearm" or "Discharging firearm" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Dischargingafirearm
	elseif script.Parent.Text == "Careless use of a firearm" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Carelessuseofafirearm
    elseif script.Parent.Text == "Pointing a firearm" or "Pointing firearm" or "Pointing gun"then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.PointingFirearm
	elseif script.Parent.Text == "Unauthorized possession of a firearm" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Unauthorizedpossession
	elseif script.Parent.Text == "Attempt to commit an offence" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Attempttocommitanoffence
	elseif script.Parent.Text == "Solicitation to commit an offence" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Solicitationtocommitanoffence
	elseif script.Parent.Text == "Conspiracy to commit an offence" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Conspiracytocommitanoffence
	elseif script.Parent.Text == "Conspiracy to commit a murder" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Conspiracytocommitamurder
	elseif script.Parent.Text == "Aiding and abetting" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Aidingandabetting
	elseif script.Parent.Text == "Operating a business w/o license" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = JailTimes.Operatingbusinesswolicense
	end
end)

(Sorry it’s long script because alot charges)

1 Like

Change it to

JailTimes["EvasionCharge"]

I don’t use dictionaries a lot so I might be wrong, tell me if it helps.

1 Like

Instead of all these if statements you can simply do

local textBox = script.Parent

textBox.FocusLost:Connect(function(enterPressed)
    if enterPressed then
        if JailTimes[textBox.Text] then
            textBox.Parent.SentenceBox.Text = JailTimes[textBox.Text]
        end
    end
end)
2 Likes

That doesn’t change the text, I like your idea but it’s not working

Maybe replace

With tostring(JailTimes[textBox.Text])?

It is for me

Your whole script should look like:

local JailTimes = {
	EvasionCharge = 450;
	TreasonCharge = 1000;
	HighTreasonCharge = 1200;
	RiotCharge = 450;
	PiracyCharge = 450;
	HijackingCharge = 600;
	BombCharge = 500;
	CausingdisturbanceCharge = 100;
	CommonnuisanceCharge = 400;
	BriberyCharge = 500;
	CourtOrder = 500;
	Resisting = 450;
	Personating = 300;
	ObstructingJ = 300;
	Publicmischief = 450;
	Prisonbreach = 600;
	Criminalnegligence = 450;
	Firstdegreemurder = 600;
	Seconddegreemurder = 550;
	AttemtedMurder = 550;
	Manslaughter = 500;
	Criminalharassment = 300;
	Utteringthreats = 300;
	Assault = 450;
	Aggravatedassault = 500;
	Kidnapping = 450;	
	Dangerousoperation  = 350;
	flightcahrge = 600;
	FailureStop = 450;
	Theft = 350;
	MotorTheft = 450;	
	Robbery = 450;
	Breakingentering = 450;
	Trespassing = 400;
	Mischief = 350;
	Arson = 600;
	DischargingFirearm = 500;
	Carelessuseofafirearm = 300;
	PointingFirearm = 400;
	Unauthorizedpossession = 400;
	Attempttocommitanoffence = 400;
	Solicitationtocommitanoffence = 300;	
	Conspiracytocommitanoffence = 300;	
	Conspiracytocommitamurder = 450;
	Aidingandabetting = 300;
	Operatingbusinesswolicense = 350 
}

local textBox = script.Parent

textBox.FocusLost:Connect(function(enterPressed)
	if enterPressed then
		if JailTimes[textBox.Text] then
			textBox.Parent.SentenceBox.Text = JailTimes[textBox.Text]
		end
	end
end)
2 Likes

Or this:

local sentence = JailTimes[textBox.Text]
if sentence then
    sentenceBox.Text = tostring(sentence)
end
1 Like

It gives this error

Hmm… Can you show how you are defining SentenceBox in your script?

Yes I am
local sentenceBox = script.Parent.Parent.SentenceBox

And is your explorer the same as shown in the script?

If it is then try using WaitForChild.

yeah it’s image

That’s weird.

It IS a ‘member of Frame’.

I honestly have no idea what’s causing this error.

so like
local sentenceBox = script.Parent.Parent.WaitForChild(SentenceBox)

No,

script.Parent.Parent:WaitForChild("SentenceBox")

I just noticed that, so yea, lemme test it

Still doesn’t work, no errors or anything

Did you try what AWhale_OfATime said?

Yeah I tried it, didn’t work out

Actually it works, but what I can do when theres 2 word things like Attemted Murder, what i can do with them?