Does anyone know the most efficient way for a Server to send a request to a Client (through a GUI Pop-up) and for the Client to respond to the Server without the Client being able to just make the GUI visible and firing the RemoteEvent/Function without even receiving the request from the Server.
This might seem easy but I know there are multiple ways, just want to know the easiest. Thanks
Just check that the server is requesting input on the server before doing anything with it. There isn’t really a reliable way to do it other than that.
Eh, I don’t think that is very reliable and also a waste of server resources to have a instance for every single request/communication I have with the client.
I mean just create one when the player joins and set it to true when the request is needed for the player and use an if statement? This isnt a waste of server resources.
Hm, that isn’t 100% though. If the Event/Function is very important, exploiters could potentially use anti-exploits to randomally generate numbers until it’s the same as one you created - unless you have a cooldown.
local randomSeed = Random.new()
local randomKey
function keysend()
randomKey = randomSeed:NextInteger(1,999999999)
remote:FireClient(plr, value, randomKey)
end
remote.OnServerEvent:Connect(function(player,val,key)
if key == randomKey then
-- blah blah blah
else
player:Kick("Invalid Key")
end
end)
It doesn’t reset the key until the next time the server requests input. Exploiters can theoretically wait till the server asks for input then exploit using that key.
Ontop of that, the code wouldn’t even work in general, as the key changes for each player, so only the last player will have the right key.
This isn’t needed you can just do what @mistrustfully has done also I am sure this is flawed so that exploiters can receive a request and reuse the key.
It generates a new key whenever there is a new valid request. there’s no way to reuse the old one. The only problem I think this might have is when you use it with multiple people.
You can reuse the key because it only generates a new one when a new player joins which also brings up problems as only the recently joined player would have the right key.
Of course it could be tweaked to work but a simple bool value would do for this case. You want to avoid things like this (key systems) as much as possible.