this is just a quick question i wanted to ask. Is there anyways you can view a players stats from datastore?
Is there anyways to view a players stats on your game?
1 answer
I'm assuming you understand how to use Data Store efficiently so I'll just explain how to make a visual example of the player's data. We'll be using leaderstats as to answer this question, BUT keep in mind that you can also show the player's data through many other ways too. In order to set up our leaderstats, we'll want to set a function that fires when a player joins. This can be done through game.Players.PlayerAdded:Connect(function(player). Next, we will add a model named "leaderstats" to the player and then add a values inside that model that represents the Data Store Values. Take this for an example,
local PrimaryData = game:GetService("DataStoreService"):GetDataStore("DataStore)
game.Players.PlayerAdded:Connect(function(player)
local LeaderStatsModel = Instance.new("Model",player) --Inserting the model into the player
if PrimaryData:GetAsync("user_"..player.UserId) ~= nil then
local NewValue = Instance.new("NumberValue",LeaderStatsModel) --What's being saved. Cash, level, exp, and etc..
NewValue.Name = "Insert whatever you want here" --Name of that value. EX: Cash, level, exp, and etc
NewValue.Value = PrimaryData:GetAsync("user_"..player.UserId) -- That value
else
--set their data to default
end
end)
1 comment
well what im trying to do is that there is this warning system, and anytime a player misbehaves, a admin gives them a warning. what i would like to do is view a certain players stats even when there not in the game
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Of course there is