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.
As I said in the comment, you're improperly using the tuple given to FireClient()
. The first thing in the tuple should not be the player, as that is already passed when OnClientEvent
fires. Fix that line like this:
RE.Jail:FireClient(msg) -- msg should be the only thing being fired to OnClientEvent, because OnClientEvent doesn't automatically pass it like it passes the player who fired the RemoteEvent.