Hello!
I am wondering what would be the greatest way to validate the legitimacy of a provided user's id.
For example:
-> Player chats
-> Provides data like 31136259 (my user id).
I can have the server check the user id if I am in-game (since it is my user id). But if I am not, then how would I check it?
The data provided can be three things: Current username, past username(s), and a user id.
GetUserIdFromNameAsync() works with the current and past usernames for getting the user id.
GetPlayerFromUserId() only works if the player associated with the id is in-game.
I haven't found anything on here, and Google hasn't really produced anything either. I would check the forums..if they weren't shut down.
I haven't really tried anything because I do not even know where to start except to use a proxy server and a bot, but I want to try and avoid that.
What would be the best approach?
Thanks for your help!
Here's the code I have so far:
-- ServerScript -- This is nested in a PlayersAdded function; that is where Player is coming from Player.Chatted:Connect(function(Message) require(script.HandleMainChat):Chatted(Player, Message) end) -- ModuleScript (HandleMainChat) function Method:Chatted(Player, Message) local MessageParts = {} for i in string.gmatch(Message, "[%a%d%p]+") do table.insert(MessageParts, i) end for i = 1, #MessageParts do if MessageParts[i] == "!Points:" then if Player:GetRankInGroup(GameSettings["SystemInfo"]["GroupId"].Value) >= GameSettings["SystemInfo"]["MinimumRank"].Value then local UserId = 0 if tonumber(MessageParts[i + 1]) then pcall(function() if Players:GetPlayerByUserId(tonumber(MessageParts[i + 1])) then UserId = tonumber(MessageParts[i + 1]) end end) else pcall(function() UserId = Players:GetUserIdFromNameAsync(MessageParts[i + 1]) end) end end elseif MessageParts[i] == "!Points" then end end return false end -- GameSettings is nested in ServerStorage -- The other objects attached to GameSettings are nested in that folder are just various Configuration settings for this