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

How do I get the number of Visits a Player has in a Script?

Asked by 4 years ago

I was Trying to get the number of Games the Player has created and Get the Total Place Visits of the Player in a Script. How would I Get the Total Place Visits and Amount of Created Games.

Local Script to make it Appear on a Gui

script.Parent.Text = "Total Visits: ".. game.Players.LocalPlayer.Visits

Visits is not Going to Work but there is an Api

0
Could make a value that increases once every time the player joins and put it in DataStore to save it. Raslito 7 — 4y
0
^ This is pretty much the only way to do it since you can't use roblox endpoints poke7667 142 — 4y

1 answer

Log in to vote
0
Answered by
gloveshun 119
4 years ago

Jou must enable studio api services to your game, then insert a script int serverscriptservice that

local sd = game:GetService("DataStoreService")
local ds = sd:GetDataStore("JoinsOfAPlayer")
game.Players.PlayerAdded:Connect(function(plr)
    local val = Instance.new("NumberValue", plr)
    val.Name = "Joins"
    val.Value = ds:GetAsync(plr.UserId)
    ds:SetAsync(plr.UserId, val.Value)
    wait()
    val.Value = val.Value + 1
end)
game.Players.PlayerRemoving:Connect(function(plr)
    ds:SetAsync(plr.UserId, plr.Joins.Value)
end)
Ad

Answer this question