How to handle skill-check via Server?

I would like to know on how can I validate the “right timing” on a skill-check via Server.

Generally, handling UI via server is objectively wrong (at least for me). And that is what is bothering me. I want to know how can I check if the player passed the skill-check legitimately without them being able to edit the parameters sent to the server.

You could try simulating the skill-check on the server and validating the client’s data by checking if the results are valid server-side, ensuring to account for any latency by using Player:GetNetworkPing(). Rather than sending data like “Passed skill-check” or “Didn’t pass skill-check”, send data informing the server the client triggered the input associated with attempting the skill-check. Then, have the server validate whether the client’s attempt was successful or not.

1 Like

As much as I wouldn’t recommend doing it on the server, you didn’t ask for advise so i’ll just answer your question. You want to offset the click time by the players latency (not ping), this will create a more accurate time when the player clicked it. Although it’s important to note that latency is not that accurate when timing replicated gui button clicks.

The code below is what I would do personally if i were to do it on the server. It is untested, as I’m not currently in studio.

local Gui = script.Parent -- or wherever it is.
local SkillCheckButton = -- path

local Player = Gui.Parent.Parent

function CreateSkillCheckConnection(minTime, maxTime, resultHandlerCallback)
   local timeNow = time()
   minTime = timeNow + minTime
   maxTime = timeNow + maxTime

   return SkillCheckButton.MouseButton1Down:Once(function()
      local ping = Player:GetNetworkPing() -- time to go from client to server and back again.
      local latency = ping / 2 -- we just need time from client to server
   
      local clickTime = time()
      local adjustedClickTime = clickTime - latency

      if adjustedClickTime > minTime and adjustedClickTime < maxTime) then
          resultHandlerCallback(true)
      else
          resultHandlerCallback(false)
      end
   end
end

local skillCheckConnection = CreateSkillCheckConnection(1, 2, function(success)
    if success then
        print("Player completed it successfully")
    else
        print("Player failed the skillcheck")
    end
end

task.wait(4)

skillCheckConnection:Disconnect() -- if they ever miss it or it cancels early.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.