Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

2 comments

0

Could make a value that increases once every time the player joins and put it in DataStore to save it.

0

^ This is pretty much the only way to do it since you can't use roblox endpoints

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.