-
What does the code do and what are you not satisfied with?
My code is a server-script which handles money per click for in-game currency. The script gets fired by remote event from client side and checks value inside player and the one which was sent by client, if these are not equal then player gets kicked out. I want to know if it is a good protection from exploiters.-
What potential improvements have you considered?
Maybe it could be much more secure and professional, that it is right now. -
How (specifically) do you want to improve the code?
I want to make it more professional and secure. (if it is possible)
-
--//SERVICES
local PS = game:GetService("Players") -- Players service!
local DS = game:GetService("Debris") -- Debris service!
local TS = game:GetService("TweenService") -- TweenService!
local RS = game:GetService("ReplicatedStorage") -- ReplicatedStorage Service!
--//FOLDERS
local EVENTS_FOLDER = RS:WaitForChild("Events") -- Folder where RemoteEvents live.
--//EVENTS
local NormalClick_Event = EVENTS_FOLDER:WaitForChild("NormalClick") -- NormalClick Event
local Change_Value_Event = EVENTS_FOLDER:WaitForChild("ChangeValue") -- ChangeValue Event (not used yet)
local MegaClick_Event = EVENTS_FOLDER:WaitForChild("MegaClick") -- MegaClick Event (not used yet)
NormalClick_Event.OnServerEvent:Connect(function(plr, CPC)
--Values
local TRUE_CPC = plr:WaitForChild("COOKIE_PER_CLICK") -- finding true Cookie Per Second's value
local COOKIE_COINS = plr:WaitForChild("COOKIE-COINS") -- Cookie Coins value. (in-game currency)
--Protection From Hackers
if TRUE_CPC.Value < CPC or TRUE_CPC.Value > CPC then -- if True cookie per second's value is not the same as the one sent by client then kick player.
plr:Kick("ANTI-CHEATER: EXPLOITING. (If you didn't exploit contact us)") -- Doesn't ban players just in-case it was a in-game bug.
return -- Returns so code will not run further if exploiter is kicked.
end
--Main Functionallity
COOKIE_COINS.Value += TRUE_CPC.Value -- Adds int-value, equal to TRUE_CPC value to cookie coins
print("CPC: "..TRUE_CPC.Value, "COOKIES: "..COOKIE_COINS.Value) -- Print's out some information for testing purposes
end)