How to Send Discord Webhook Messages When Someone Joins

Im trying to make that everytime someone joins i will get message in discord by webhook

1 Like

Welcome to the CookieTech forums! :wave:

There is a way to send a webhook when someone joins, and I have a whole model for it, it’s called “ezLOG”. Here is it ezLOG if you want to use it. Don’t forget to use this webhook proxy.

am i late??? anyways:


Steps

  1. you need to use a PROXY for this
    i recommend using this proxy: https://webhook.lewisakura.moe
  2. make your webhook in the desired discord channel
    from discord articles:

  3. copy the webhook URL by pressing this button:
    image
  4. go to the https://webhook.lewisakura.moe website, it’ll load their converter, paste your link and convert it:
  5. save the output smwhere since you’ll need this later

now hop into roblox studio and follow these steps:

  1. insert a new Script (ServerScript) into ServerScriptService and name it whatever the hell you want
  2. replace the default:
print("Hello World!")

code with this:

local targetUrl = "https://webhook.lewisakura.moe/api/webhooks/" --Discord webhook URL, input urs here
local GAME_NAME = "ornagebird3's gmae 🤯" --The name of the game
local GAME_IMAGE = "" -- if ya want, u can set a thumbnail for the game in the Discord bot

local http = game:GetService("HttpService")
local ds = game:GetService("DataStoreService"):GetDataStore("PlayerJoinLogger")
local DataStoreName = "PlayerSave_" -- key prefix | DataStoreName..plyr.UserId

function CreateSave(plyr)
	local obj = {
		JoinTime = os.time(),
		DataVersion = 1
	}
	http:JSONEncode(obj)

	ds:SetAsync(DataStoreName..plyr.UserId,obj)
end

function NewJSON(content,username,avatar_url)
	local obj = {
		['content'] = content,
		['username'] = username,
		['avatar_url'] = GAME_IMAGE
	}

	return http:JSONEncode(obj)
end

game.Players.PlayerAdded:connect(function (plyr)
	local saveData = ds:GetAsync(DataStoreName..plyr.UserId)
	if not saveData then
		CreateSave(plyr)

		local msgObj = NewJSON(plyr.Name.." has joined for the first time. ID: "..plyr.UserId,GAME_NAME)		
		http:PostAsync(targetUrl, msgObj)

	elseif os.time() - saveData.JoinTime > 86400 then -- check if player did not join <24 hours ago, comment this out if u want to log every join
		CreateSave(plyr)

		local msgObj = NewJSON(plyr.Name.." has joined a game. ID: "..plyr.UserId,GAME_NAME)		
		http:PostAsync(targetUrl, msgObj)
	end
end)
  1. in that code, edit the targetUrl variable;
    just paste the link you copied or saved earlier within the quotation marks
  2. you can edit other variables and other sections of the code if you’d like (i left comments there)

yeah uh im too lazy to explain the code so erm


LAST AND MOST IMPORTANT STEP!!!

step 5.

mark me as solution :pleading_face::pleading_face::pleading_face: (even if i didn’t help /j)

oh yeah and dont forget to close out of ur script to save it !!

TYSM!!! it helped! here is ur solution :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.