Ayo, Was wondering if there is a better way doing this code:
Server:
local event = game:GetService("ReplicatedStorage").CheckPlayer
local text = game.StarterGui.MainUI.Frame.TextBox
event.OnServerEvent:Connect(function(p, ingame)
if ingame == "PlayerInGame" then
.
elseif ingame == "PlayerNotInGame" then
.
end
end)
Local:
local event = game:GetService("ReplicatedStorage").CheckPlayer
script.Parent.MouseButton1Click:Connect(function()
if game.Players:FindFirstChild(script.Parent.Parent.TextBox.Text) then
event:FireServer("PlayerInGame")
elseif not game.Players:FindFirstChild(script.Parent.Parent.TextBox.Text) then
event:FireServer("PlayerNotInGame")
end
end)
In this case, I think it’s a bit redundant. A player can’t fire a remote if they’ve disconnected from the game. If they’ve fired a RemoteEvent, you should be safe to assume they are in-game. As a side-note, I would handle your sanity checks on the server versus checking on the client and having the client then send the server the value, since it’s less secure that way.
You don’t necessarily need to make a table for storing players and checking if they left or not, but I wouldn’t recommend using Remote Events since exploiters can get to that.