You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I want to properly implement the checks so that I dont have to worry abt players getting inf coins.
What is the issue? Exploiters have been giving themselves inf coins by somehow bypassing the serverside checks.
What solutions have you tried so far? This is the serverside code that checks the amt and if it is correct or not:
Event.OnServerEvent:Connect(function(player : Player, amt)
local profile = module.Profiles[player]
if not profile then return end
if not amt then
print("nil amt: " .. player.Name)
return
end
if amt ~= amt then
warn("nan amt: " .. player.Name)
return
end
if type(amt) ~= "number" then
warn("invalid type on amt: " .. player.Name)
return
end
if amt < 1 or amt > 10 then -- not sure how exploiters are getting past this but they are
warn("invalid amt: " .. player.Name)
return
end
if (profile.Data.Coins + amt) - profile.Data.Coins > 10 then -- this might be redundant with the check above but i wanted to make sure
print("amt is too large: " .. player.Name)
end
if tick() - playerTable[player.Name] > cooldownTime then -- cooldown / delay to prevent spamming (1.5s)
playerTable[player.Name] = tick()
profile.Data.Coins += amt
player.leaderstats.Coins.Value = profile.Data.Coins
else
return
end
end)
The remote event is fired when the player uses their tool (which gives them coins). The amt refers to the amount of coins being added to the players data. Though I don’t want exploiters accessing the event, its easy for them to use a remote spy and do what they want with it.
could they be spamming the remote? They could still be getting 10 coins per fire, just insanely quickly. You could add a debounce and discard any event which comes during that debounce time.