Hi, i am trying to make a ban/Unban system, in this case, the admin writes down a name of a player to ban, but i want it to ban the player even though he is offline or in another server. Is there any way to check if the player written exist?
2 Likes
It is possible to do this using two functions provided by the Players service. I suggest you read the documentation for the Players service and DataStore service. I have provided some of these below.
Players:GetUserIdFromNameAsync
Players:GetNameFromUserIdAsync
4 Likes
This will work, ensure you wrap it in a pcall though, as it will error your script without (whether the async fails or not, if the username doesn’t exist, it’s going to error).
local success, content = pcall(function()
print('Here is my pcall function!')
end
if success then
warn('Successful!')
end
This will error because ‘ansdnjkasdkjnasd’ isn’t a value.
local success, content = pcall(function()
print(ansdnjkasdkjnasd)
end
if not success then
warn('Unsuccessful! Error message: '..content)
end
2 Likes
oh, okay, Thanks a lot, i did not know that existed,i will read that documentry thanks a lot
2 Likes