Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

For some reason my arrest system is not working, any help?

Asked by 6 years ago
Edited by User#5423 6 years ago

The script works fine, but it doesnt keep the player in jail if they reset. Heres the script

001JailPos = script.Parent.JailPosition.Value
002 
003FreemanPosition = Vector3.new(5, 4, 191)
004 
005JailedFolder = script.Parent.JailedPlayers
006 
007   
008 
009   
010 
011function TeleportPlayer(Plyer,Pos)
012 
013if Plyer.Character ~= nil then
014 
015local HMRP = Plyer.Character:FindFirstChild("HumanoidRootPart")
016 
017if HMRP then
018 
019HMRP.CFrame = CFrame.new(Pos)
020 
021end
022 
023end
024 
025end
026 
027   
028 
029function PlayerFromName(Nam)
030 
031local Search = game.Players:FindFirstChild(Nam)
032 
033if Search then return Search else return nil end
034 
035end
036 
037   
038 
039function GiveJailGui(Plyname)
040 
041local Play = PlayerFromName(Plyname)
042 
043if Play then
044 
045if Play.PlayerGui then
046 
047local JG = script.JailedGui:Clone()
048 
049JG.Parent = Play.PlayerGui
050 
051JG.GUpdater.Disabled = false
052 
053end end end
054 
055   
056 
057function GiveFreemanGui(Plyname)
058 
059local Play = PlayerFromName(Plyname)
060 
061if Play then
062 
063if Play.PlayerGui then
064 
065local FG = script.PlayerFree:Clone()
066 
067FG.Parent = Play.PlayerGui
068 
069FG.CloseScript.Disabled = false
070 
071end end end
072 
073   
074 
075function ClearName(PlyName)
076 
077local fin = JailedFolder:GetChildren()
078 
079for i = 1,#fin do if fin[i].Name == PlyName then
080 
081fin[i]:Destroy()
082 
083end end
084 
085end
086 
087   
088 
089function HandleJailTime(PlyName,TimeToServe)
090 
091ClearName(PlyName)
092 
093local Timer = Instance.new("IntValue")
094 
095Timer.Name = PlyName
096 
097Timer.Parent = JailedFolder
098 
099Timer.Value = TimeToServe
100 
101coroutine.wrap(function()
102 
103for i = 1,TimeToServe do
104 
105Timer.Value = Timer.Value - 1
106 
107wait(1)
108 
109end
110 
111Timer.Value = 0 wait(1) Timer:Destroy()
112 
113end)()
114 
115end
116 
117   
118 
119function JailPlayer(Caller,PlyN)
120 
121local JPlayer = PlayerFromName(PlyN)
122 
123if JPlayer then
124 
125if JPlayer.Backpack then JPlayer.Backpack:ClearAllChildren() end
126 
127if not JPlayer.PlayerGui:FindFirstChild("JailedGui") then
128 
129HandleJailTime(PlyN,90)
130 
131TeleportPlayer(JPlayer,JailPos)
132 
133GiveJailGui(PlyN)
134 
135end end
136 
137end
138 
139   
140 
141script.Parent.OnServerEvent:connect(function(Caller,Prisoner,format)
142 
143if Caller then if Prisoner ~= nil then if format ~= nil then
144 
145if format == "Jail" then
146 
147JailPlayer(Caller,Prisoner)
148 
149elseif format == "Confirm" then
150 
151local CGui = script.JConfirmGui:Clone()
152 
153local CopPGUI = Caller:FindFirstChild("PlayerGui")
154 
155if CopPGUI then
156 
157if not CopPGUI:FindFirstChild("JConfirmGui") then
158 
159CGui.Parent = CopPGUI
160 
161CGui.TargetPlayer.Value = Prisoner.Name
162 
163CGui.ArrestPlayer.Disabled = false
164 
165end end
166 
167elseif format == "Freeman" then
168 
169TeleportPlayer(Caller,FreemanPosition)
170 
171ClearName(Caller.Name)
172 
173GiveFreemanGui(Caller.Name)
174 
175elseif format == "BackToJail" then
176 
177TeleportPlayer(Caller,JailPos)
178 
179elseif format == "BackToJailNP" then -- where when the player respawns, they should be in jail still, which for some reason does not.
180 
181TeleportPlayer(Caller,JailPos)
182 
183GiveJailGui(Caller.Name)
184 
185elseif format == "ClearJGUIs" then
186 
187local ser = Caller:FindFirstChild("PlayerGui") if ser then
188 
189local search = ser:GetChildren()
190 
191for i = 1,#search do
192 
193if search[i].Name == "JConfirmGui" or search[i].Name == "JailedGui" or search[i].Name == "PlayerFree" then
194 
195search[i]:Destroy()
196 
197end end end
198 
199end
200 
201end end end
202 
203end)
0
Maybe you can attach it as a script so it's easier to read? MrDaniel_TX 5 — 6y
0
use code block pls User#5423 17 — 6y
0
Okay Pooglies 7 — 6y

1 answer

Log in to vote
0
Answered by 5 years ago

Here is that script but in a code block. Next time please consider posting questions with a cod block.

001JailPos = script.Parent.JailPosition.Value
002 
003FreemanPosition = Vector3.new(5, 4, 191)
004 
005JailedFolder = script.Parent.JailedPlayers
006 
007function TeleportPlayer(Plyer,Pos)
008 
009if Plyer.Character ~= nil then
010 
011local HMRP = Plyer.Character:FindFirstChild("HumanoidRootPart")
012 
013if HMRP then
014 
015HMRP.CFrame = CFrame.new(Pos)
View all 185 lines...

I did not format anything from the script but only made it have a code block.

Ad

Answer this question