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

Is there anyways to view a players stats on your game?

Asked by 6 years ago

this is just a quick question i wanted to ask. Is there anyways you can view a players stats from datastore?

2
Of course there is BlackOrange3343 2676 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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)
0
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 cruizer_snowman 117 — 6y
Ad

Answer this question