Voice chat isnt working (Discord webhooks)

  1. What do you want to achieve?
    I know that official vc has been released.

But one of my friend wanted to create one using roblox script lua.
Also how’s the voice chat is gonna work is when player enters this region, they will hear someone in that region using discord vc

  1. What is the issue? Include screenshots / videos if possible!

When I test for myself its working. But when my friend tried to test it, it didnt work out

ServerScriptService.RegionScript:27: attempt to concatenate nil with string - Server - RegionScript:27

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I didn’t found any in social medias

Im gonna censored some code

REGION VC SCRIPT :

local playerInZones = {}

local httpService = game:GetService("HttpService")
local url = "https://discord.com/api/webhooks/" --Censored it

local channelIDs = {
	["Zone1"] = ""; -- Censored it
	["Zone2"] = "" -- Censored it
}

local playerDiscordIDs = { -- Censored it
	[""] = ""; -- Censored it
	[""] = ""; -- Censored it
	[""] = ""; -- Censored it
	[""] = "" -- Censored it
}

game.Players.PlayerAdded:Connect(function(player)
	playerInZones = {
		player.Name == nil
	}
end)

local function formCommand(playerName, Zone)
	local playerDiscordID = playerDiscordIDs[playerName]
	local channelID = channelIDs[Zone]
	local commandText = "~move " .. playerDiscordID .." ".. channelID
	
	print("Past move")
	
	return commandText
end

local Zones = game.Workspace:WaitForChild("Regions")

while wait(1) do
	for _, zone in pairs(Zones:GetChildren()) do
		local region = Region3.new(zone.Position - (zone.Size/2), zone.Position + (zone.Size/2))
		local partsInRegion = game.Workspace:FindPartsInRegion3(region)

		for _, part in pairs(partsInRegion) do
			if part.Parent:FindFirstChild("Humanoid") then
				local character = part.Parent
				local player = game.Players:GetPlayerFromCharacter(character)

				if playerInZones[player.Name] ~= zone.Name then
					print("player is not in the zone")

					local commandText = formCommand(player.Name, zone.Name)
					print(commandText)

					local data = {
						["content"] = commandText;
					}					

					local finalData = httpService:JSONEncode(data)
					httpService:PostAsync(url, finalData)

					playerInZones[player.Name] = Zones.Name

				else
					print("Player is already in region zone")
				end

				break
			end
		end
	end
end

WEBHOOKS SCRIPT :

local url = "https://discord.com/api/webhooks/" -- Censored it

game.Players.PlayerAdded:Connect(function()
	local data = {
		["content"] = "Succesfully Online";
	}
	
	local finalData  = httpService:JSONEncode(data)
	httpService:PostAsync(url, finalData)
end)
1 Like

Yes I want to insert player’s name into the playerInZones table

2 Likes

My apologies, just realised that discord banned Roblox calls, or there’s currently some issues between Roblox and discord. Their have been other posts on the topic but I’m not sure where exactly.

Sorry for those who already reply, I already figured it out.

Just need to change player discord ID to their original name on Roblox