Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to get a player's rank when he's not in the game & How to get a player's ID from an Username?

Asked by 10 years ago

The thing is that I am making a database of players for my group, and I want to add a notification if a player is in the group (there is a search bar, then I click load and it load the information from Data Storage) I also would like to know how to get information from a player (MembershipType and AccountAge)

The solution I found is to create a Player, then set it's ID with a script (2nd Question) But this solution is imposible, because you cannor create an instance player.

0
I don't really know how to do this, but in the group RAT, they have an info center which stores your information AFTER you play it for the first time. Try doing that! (Sorry I really can't help on this.) xolbStudios 127 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

to get info on a player while the are offline you need datastores. period. Essentially, you need to use a few stores with the key unique per player (player.userId, NOT their name).

ds = game:GetService("DataStoreService")
rank = ds:GetDataStore("Rank")
GroupID = 1337

game.Players.PlayerAdded:connect(function(player)
rank:UpdateAsync(player.userId,function(old) return old or 1 end)
local int = Instance.new("IntValue",player)
int.Name = "Rank"
if player:IsInGroup(GroupID) then
local real = player:GetRankInGroup(GroupID)
int.Value = real
else
int.Value = 1
end
end)

also, make sure that it saves their stats when they leave

game.Players.PlayerRemoving:connect(function(player)
rank:SetAsync(player.userId,player:WaitForChild("Rank").Value)
end)

Its been a while since I've done group stuff, so the GetRankInGroup and IsInGroup are probably wrong, but that is a quick switchout with whatever is on the object browser and/or wiki. The logic still stands, however, and you can add more info like account age and other misc. stuff.

0
This is only updating someone's rank when they enter the game, I already used DataStore to save ranks but admins change it, because i didn't wanted to make like( if player.Rank == ranknumber then Gui.Rank .Text= "RankName") tyopido 0 — 10y
Ad

Answer this question