Would this code help against exploiters?

Players = game:GetService(“Players”)
local claimdistance = 10
local claimed = false
local check = true

script.Parent.PromptButtonHoldBegan:Connect(function(player)
if script.Parent.PromptButtonHoldBegan then
script.Parent.HoldDuration = script.Parent.Triggered
local price = 0
if price >= 0 then
if check == true then
if player.Name and check == true then
if claimed == false then
if player.UserId and claimed == false then
print(“HexticDev Made This <3”)
end
end
end
end
end
end
end)

Idk if it is possible to really “secure” your game but I figured if you made certain requirements to be checked it might help…

Nope:

  • You almost use multiple debounce variables (claimed and check), which is a good first step, but you never actually change their values - meaning they don’t do anything.

  • You have multiple lines that’ll always return true and aren’t necessary (player.UserId). There’s also a few lines which will likely error (if script.Parent.PromptButtonHoldBegan then and script.Parent.HoldDuration = script.Parent.Triggered)

  • The closest thing to an “anti-exploit” for this is to do a distance check between a triggering player’s character and the ProximityPrompt and ensure it makes sense.

  • If this is all client-side (a LocalScript), prevention is mostly pointless aside from debounces. If this is server-side, with my aforementioned changes it will do a decent job.

TL;DR: Use your debounces, remove most of the fluff, and do a distance check.

2 Likes

Def did not error thanks though. Also its defined above.