I am making a shooter game and I want to add aimbot to my game for all developers to use. I have already made the whitelist method, I just need to know how to make the camera lock on to the nearest player in a LocalScript in StarterPlayerScripts.
This is the code that they used to make the player rotate around a part:
If someone solves this problem then the only thing I need to know is how to detect the nearest player, or should I do it based on an fov system?
I know some people get annoyed when people ask them to write the code for them, but I'm not a skid and I actually want to learn how the code works as well. If you write the code that would be a huge help, but please explain as well if you do. And if you just explain it, not write it, that will be fine too!
Hi, was going to reply in the comments but I locked the thread thinking you wanted us to write an entire aimbot script instead of what you actually asked. Sorry about that.
I don't suggest giving your admins aimbot. It's a bit abusive to other players who are playing your game fairly. The tread got locked because you need to be more specific about your question. Only have your post ask one question instead of multiple. If you have a load of questions or don't know where to start, we have a live chat and a discord server where you can bounce your ideas off people. Lot quicker getting help there than it is here really.
To answer a part of your question, here's how to check for the closest player:
To get the closest player you can use magnitude: https://developer.roblox.com/en-us/articles/Magnitude
or you can use DistanceFromCharacter() https://developer.roblox.com/en-us/api-reference/function/Player/DistanceFromCharacter
they both do the same thing
--[[ have a variable called `smallestMagnitude` and another one called `closetPlayer`. loop through all the players check if their magnitude from our local player is smaller than smallestMagnitude make that our closest player ]]
up to you if you want to make it fov or not.
Closed as Not Constructive by hiimgoodpack and royaltoe
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?