Yup. Use the ProximityPrompt’s parent’s position and subtract that from their HumanoidRootPart position, and get the magnitude from that. Check if that magnitude is less than the ProximityPrompt’s MaxDistance (plus a small amount), and only run the code if that is true. I’ve done this before and it works perfectly.
local part = script.Parent
local ProximityPrompt = script.Parent.ProximityPrompt
ProximityPrompt.PromptTriggered:Connect(function(player)
local char = player.Character
local magnitude = (part.Position - char.HumanoidRootPart.Position).magnitude
if magnitude <=10 then
--my code
end
end)
yes that would work, keep in mind exploiters can just change their root cframe so that they are in the 10 studs radius of the proximity prompt. This is not as secure as if you would have a server tp check to detect this.
what you have now is ok, it will at least stop exploiters from firing the proximity prompt from a long distance. But if you know what you’re doing you could make the checks on the client (checking if they are holding down the keys and how long they are doing it for and then sending something to the server)
the distance check is server sided i am assuming but what i’m trying to say is when exploiters change their root cframe it replicates to the server. Making the magnitude check client sided would only make it 100x easier to bypass the magnitude check
Its not that simple. The exploiter would still be able to fire the events that would be responsible for verifying it. The basic rule for client-server communication is never trust the client. It isn’t really possible to verify anything unless done entirely on the server. The most that solution would do is make it a tiny bit more annoying to exploit and take up your time trying to script it.
people who say, “never trust the client” are the ones to make the most basic anticheats. If you know what you’re doing like i said, you can make great client checks along with server checks
Its impossible to to make any client checks. Exploiters can simply delete/disable and localscript they want. They have absolute control over most, if not all, of the client’s scripts. It’s better to live never trusting the client than trying to make some strange local anticheat and expect it to work.