Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Anti-Tool Insert Exploit?

Asked by 9 years ago

I'm working on an anti-expoit script right now that kicks a player if they insert tools into their backpack. Since I allow some gears into my game and I have givers that insert tools into the backpack, I had to add some extra parameters. The script is supposed to first check all the backpack tools, and if some tools don't exist in the StarterGear, then check if they exist in StarterPack, and if they still don't match, check if they have a boolvalue named "Tool" in them. I added this boolvalue into all the tools that I give to players, so if they don't have this, then it must be an exploited tool. For some reason, when I test on the studio, it breaks on line 7, saying it is indexing a nil value. Please help!

while true do
local p = game.Players:GetChildren()
for i = 1, #p do
if p[i] ~= nil and p[i]:FindFirstChild("Backpack") and p[i]:FindFirstChild("StarterGear") then
local t = p[i].Backpack:GetChildren()
for i = 1, #t do
if p[i].StarterGear:FindFirstChild(t[i].Name) == nil then 
if t[i]:FindFirstChild("Tool") then
else
p[i]:Kick("Don't exploit!")
end
end
end
end
end
wait (5)
end

1 answer

Log in to vote
0
Answered by
Uglypoe 557 Donator Moderation Voter
9 years ago

Instead of making a While Do statement, try making a .ChildAdded statement that checks the same types of parameters, but fires whenever a tool is added to a players backpack. For example:

game.Players.PlayerAdded:connect(function(plr)
plr:WaitForChild("Backpack").ChildAdded:connect(function(tool)
if not tool:FindFirstChild("Tool") then
plr:Kick("Don't exploit!")
end end) end)

I would recommend editing this short code I wrote for you to accommodate more for your needs. However, I would highly recommend going along this route instead, it will be more reliable and less expensive server-wise.

If you need any more help, leave a comment. :)

Ad

Answer this question