#UI games how would be the best way prevent exploits on client

1 messages · Page 1 of 1 (latest)

snow bough
#

GUI games are all controlled by the client (since you only want the client to see the game at once) how could i prevent people using exploits (hacks) to just immediately win.

In my case i have a crate spin BUT the twist is that the player presses stop to win an item.. does using fireserver(itemwon) be good enough or could players just change the "itemwon" to anything they wanted if they used scripts?

quiet sierra
knotty ledgeBOT
#

studio** You are now Level 1! **studio

dull quiver
snow bough
#

ill need to use a remote event but also using remote events can be used to explot

dull quiver
#

Sorry, yes it is. Let me be more clear for your case; you need to fire a remote event to the server calling it to crate spin. The logic of actually doing RNG to get an item needs to be ran on server side

#

Remote function would be better for this case as it is easier to replicate it to the client in the UI, but remote event would work

dull quiver
knotty ledgeBOT
#

studio** You are now Level 2! **studio

snow bough
#

yes that is correct- sadly that would be easier said than done - this isnt completely rng... its skill based so when the player presses 'stop' the crate will just land on the item do i do all of this server side and just remoteevent:FireServer('pressStop')

dull quiver
#

so you would do
local ItemWon = :InvokeServer(RollCase)
local ItemWonDisplay.text = ItemWon

snow bough
#

because tweening on the server isnt ideal either

dull quiver
#

Yes that is right. Honestly I am not sure how that would be done off the top of my head. My first thought is to use a table with the same index as the crates in the ui, and then based on time spent before stopping, it detects what the stopped item is

#

you would need a variable like:
local TimePerItem = 0.5 -- Every item is being hovered over for half a second before going on to next item

snow bough
#

yeah i just do tween:Pause() and i get all the items in the frame and print the one thats in the correct position

#

i do have a script i dont like sending cuz i dont want peopl stealing lol

#

it works but its currently 100% on the client until i figure out how to fix it

#

it was just easier to get it working first THEN get it secure after

dull quiver
# snow bough it was just easier to get it working first THEN get it secure after

Client

.MouseButton1Click:Connect(function()
Local SelectedCase = ui:GetAttribute("SelectedCase")
local ItemWon = RF:InvokeServer("OpenCase", SelectedCase)
print("Won item; " .. ItemWon
end)

Server

local CaseData = {"Item 1", "Item 2", "Item 3"} -- Casedata should be a module script. If you want to randomize order every time you need to make a server side function to do so

local IsSpinning = {} -- UserID: SpinTick
local TimePerItem = 0.5

local function SpinCase(Player:Player, CaseData)
      local TotalItems = #CaseData
       
      if not IsSpinning[Player.UserId] then
        print("IsSpinning")
        IsSpinning[Player.UserId] = tick()
      else
        local SpinTime = IsSpinning[Player.UserId]
         local SpinDuration = tick() - SpinTime

          local CycleTime = TotalItems * TimePerItem
          local TotalTime = SpinDuration % CycleTime
          local IndexItem = math.round(TotalTime / TimePerItem) % TotalItems + 1
           print("StoppedSpinning. Indexed Time; " .. TotalTime .. " Won Item; " .. CaseData[IndexItem] )
          IsSpinning[Player.UserId] = nil
end)

RF.OnServerInvoke = function(Player, Event, Data) -- Data should be string for this event
  if Event == "OpenCase" and Data then
    -- Check if enough coins or whatever
    SpinCase(Player, Data)
  end
end
#

Let me know if I left anything crucial out, and you will def need to work on the math for sure for more accurate results, you have to account for server delay and such which I didn't take the best approach for, but I am high as hell and the math is killing my brain lol

snow bough
#

yoo sorry im back ill let you know!!

snow bough
#

coding takes a lot of time so i really appreciate this

#

i do have a script already

dull quiver
#

nah ur chillin man the job aint finished yet i did that math probably horribly

snow bough
#

i will integrate this if possible

#

nah you're all goods

dull quiver
#

Even if you define CaseTypes and their items on server side for extra validation, they'd be able to give themselves any item in that case

snow bough
#

all i want to send from the client is 'stop button pressed' and let the server handle everythijng

dull quiver
#

that's what the script I provided above does, it looks a little odd since I made both the same function but I prefer it that way personally

#

First press ; opens case and adds user to table verifying their status
Second press; grabs tick of when started, and does the code to detect item won

snow bough
#

dude my code is a lot worse than yours btw

dull quiver
#

I've just realized a cruical error in my code so let me edit it

#

This at the end of getting the item won is cruical

IsSpinning[Player.UserId] = nil
snow bough
#

ill send you dm of my code if you like(i dont mind sending just not super keen on too many people seeing it and maybe just stealing it) - which is currently completely on the client side