Hey there, I am trying to make a remote that will basically fire when a player activates the tool. But then I remember that exploiters can easily see the remotes that fired and that is the main problem. I basically run a remote which pass an argumant for the amount of stats to give. The code:
local strength = 1
local remote = game:GetService("ReplicatedStorage"):WaitForChild("strengthgiver")
script.Parent.Parent.Activated:Connect(function(plr)
remote:FireServer(strength)
end)
is there any way to make it in other way that would be easy to change?
You can create list of tools with values and put this in ServerStorage and send only name with remote event and In server check how many point you should add. Or you can get tool from Chraracter
Beware that you can indeed make your RemoteEvents more secure, But you can’t make it 100% anti-exploitable, As there’s always gonna be a way to break it somehow.
When the main game logic (on this case, Clicking) comes from the Client, Everything else should be done on the server to avoid as much problems as possible.
Since the Client’s only job is to click the Button to fire the RemoteEvent, You must calculate everything on the Server (Such as Boosts, Superpowers, Powerups, etc) and make the default value 1.
We can simply imagine we have a Script on the Server and one on the Client. On the server, It’ll listen to the RemoteEvent and calculate the Amount needed to award the Player - No extra arguments needs to be passed once firing from the client. Meanwhile on the client, Just fire the RemoteEvent once a certain button is clicked.
One thing that can make it more secure is implementing a cooldown system on the server, Even if a exploiter makes a loop that fires the Remote several times per second, The cooldown will still work. Most clicker games use this strategy.
-- Server
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StrengthGiver = ReplicatedStorage:WaitForChild("StrengthGiver")
StrengthGiver.OnServerEvent:Connect(function(Player: Player)
-- Below, We can calculate certain things.
-- ... Such as if the Player has a 2x Strength Gamepass, etc.
local Leaderstats = Player.leaderstats
local Strength = if Leaderstats then Leaderstats:FindFirstChild("Strength") else nil
local Amount = 1
if not Strength then
return
end
Strength.Value += Amount
end)
-- Client
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StrengthGiver = ReplicatedStorage:WaitForChild("StrengthGiver")
local Button = script.Parent
Button.Activated:Connect(function()
StrengthGiver:FireServer()
end)