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

Is there a way to record a log which records which player joins when?

As told above in the title.

Is therw an option that registers when and which player joined your game?

i know there was a long time ago a script like this which works with a Google-script thing, but i can't find it anymore :-(

1 answer

✓ Accepted answer

Hello! So I recently answered a question that was very similar to this here: https://scriptinghelpers.org/questions/76746/getting-names-of-player-who-played-your-game#72029

The below script uses the Https Service to send a message to Discord (assuming you've set-up a webhook) that will record the time stamp and the user.

Server Script

local HTTP = game:GetService("HttpService")
local DSS = game:GetService("DataStoreService")
local Storage = DSS:GetDataStore("BasicInfo")
local webhook = "https://discordapp.com/api/webhooks/0"

game:GetService("Players").PlayerAdded:Connect(function(player)
	local newdata = Instance.new("BoolValue")
	newdata.Name = "HasPlayed"
	newdata.Value = false

	local success, result = pcall(function()
		Storage:GetAsync(player.UserId)
	end)

	if success then
		newdata.Value = Storage:GetAsync(player.UserId)
	else
		warn(result)
	end

	if newdata.Value == false then
		newdata.Value = true
		local msg = "Joined the Game"
		local payload = HTTP:JSONEncode({content = msg, username = player.Name.." - (#"..player.UserId..")"})
		HTTP:PostAsync(webhook, payload)
		print("Complete")
		Storage:SetAsync(player.UserId, newdata.Value)
		print("Saved")
	end
end)

This will add a BoolValue to the player, then check if they have any data pertaining to having already played (the pcall is to prevent errors).

If they don't have any data, the game will set the value to true and then send a message to your webhook and save the datastore.

Make sure HTTPs Service is accessible via: Studio --> Home --> Game Settings

EDIT

Recording Players Everytime they join doesn't require a DataStore Check

local HTTP = game:GetService("HttpService")
local webhook = "https://discordapp.com/api/webhooks/552233906020155393/INkYo365wvK24Haoxk2JSZPdRZGpQHiI29ViQB-WXxUZ-ENM5-fu4MxZa3h-Cp0Ct9GR"

game:GetService("Players").PlayerAdded:Connect(function(player)
	local msg = "Joined the Game"
	local payload = HTTP:JSONEncode({content = msg, username = player.Name.." - (#"..player.UserId..")"})
	HTTP:PostAsync(webhook, payload)
	print("Complete")
end)

2 comments

0

I don't know what a webhook is. Sorry :-D,. I'd like to know how it works or if you could help me with that :-). Do you mind if i contact your through roblox?

0

Sure, or on Discord, if you have it, SerpentineKing#0155

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