so I have a remote event, on my server script I sent over ‘players’ in the argument. And in the local script I remove the local players backpack items using the ‘Players’ argument
If a hacker can change the argument sent in the remote event, how can I make sure his tools/items in backpack were removed and he didn’t change the argument to something else.
Or is it only if the local script is sending data back to the server that you need to be worried and have a check to make sure the argument is infact what was sent on the local script?
If the question is checking if the player has a tool or not you can use :FindFirstChild() in the backpack or character to find out.
if Character:FindFirstChild("ToolName") then
-- Character has the tool equipped
if Player.Backpack:FindFirstChild("ToolName") then
-- Player has the tool in their backpack
If you use ~= then the if statement will pass if it doesn’t have the tool in whichever it is.
You can access a player’s backpack from a server script using the player argument. It doesn’t have to be done locally, nor should it be done locally since exploiters / hackers could delete local scripts listening for the event, in addition to the concern you expressed.
Example of a server script removing a players backpack items:
local backpack = player:FindFirstChildOfClass("Backpack")
local items = backpack:GetChildren()
for _, item in pairs(items) do
item:Destroy()
end
Hope this helps!
Edit:
This would be used to remove all players backpack items if you need it:
local players = game.Players:GetChildren()
for _, player in pairs(players) do
local backpack = player:FindFirstChildOfClass("Backpack")
local items = backpack:GetChildren()
for _, item in pairs(items) do
item:Destroy()
end
end