This is the error I am getting. (https://gyazo.com/dc156d15e39ecb4eb8ea3e025d78f253)
So I am trying to make this FE compatible so it can't be hacked and reliable. This is my code.
LocalScript:
local RE = game:GetService("ReplicatedStorage")
RE.Jail.OnClientEvent:Connect(function(plr, msg)
if msg:sub(1,6) == "/jail " then
local TargetPlayer = game.Players:FindFirstChild(msg:sub(7))
if TargetPlayer then
local CJT = TargetPlayer:FindFirstChild("leaderstats"):FindFirstChild("Jail Time")
CJT.Value = 10
local JG = game:GetService("ReplicatedStorage"):FindFirstChild("JailGUI"):Clone()
JG.Parent = TargetPlayer:FindFirstChild("PlayerGui")
while wait(1) do
CJT.Value = CJT.Value - 1
JG.Holder.Time.Text = CJT.Value
if CJT.Value == 0 then
TargetPlayer:FindFirstChild("PlayerGui"):FindFirstChild("JailGUI"):Destroy()
CJT.Value = 0
TargetPlayer:LoadCharacter()
end
end
end
end
end)
ServerScript:
game.Players.PlayerAdded:Connect(function(plr)
local ls = Instance.new("IntValue",plr)
ls.Name = "leaderstats"
ls.Value = 0
local jt = Instance.new("IntValue",ls)
jt.Name = "Jail Time"
local defval = 0
jt.Value = defval
plr.Chatted:Connect(function(msg)
local RE = game:GetService("ReplicatedStorage")
RE.Jail:FireClient(plr,msg)
end)
end)
The local script is in StarterGui named JailSetter, the ServerScript is in ServerScriptService named Stats, and the Remote Event is in ReplicatedStorage named Jail. The JailGUI is in ReplicatedStorage. I have been coding for almost a year, then took a long break. Some help getting back into the swing of things would be very appreciated.

5 comments
"msg" is being assigned to "plr". The first parameter passed by OnClientEvent is always the player yet the player should not appear in the tuple given to FireClient().
Now I am getting the error unable to cast value to to Object on line 12 of the Server Script?
please please please use the freaking Lua code button
killerbrenden the problem is I can not see the full script of the CJT value please write it
The CJT is an abbreviation for Change Jail Time which Jail Time is inside the players leaderstats thats on the leaderboard, it's a new variable that acts as the changing value for the value of jail time.