Help with script

What is wrong with me script!
I want it so when I touch a part, my discord bot moves me to a discord voice channel.

local HTTPService = game:GetService("HttpService")
local url = https://tinyurl.com/3hb8kntv

local playerDiscordIDs = {
	["Nahid"] = "760568489772974110";
}

local channelIDs = {
	["Zone1"] = "912339681050492959";
	["zone2"] = "912357629563645972";
}

local playerInZones = {}

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
	
	return commandText 
end

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

while wait(1) do
	for i,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 char = part.Parent
				local player = game.Players:GetPlayerFromCharacter(char)
				
				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] = zone.Name
					
					
				else
					print("player is already in zone")
				end
				
				break
			end
		end
	end 
end

Webhooks are not able to do that. You might need something way more advanced, like a web request to a hosting service that also hosts the bot at the same time, and make those communicate.

Also, go and change the link of that webhook immediately.

Why should I do that? Why? Why!

Because a webhook is unable to do more than send a message to a specific channel. Bots have way more control, but they need a lot more work to do what you want them to do.

Can anybody help me? Please and thank you!

As @kndn_v said creating smth lik tht wud b difficult. I dont know if this mite help u but there is a helpful module called RoboVS which basically does the same thing with a few differences however if u want to edit it u need to know about discord.js, which i guess is the lang in which it is written in. Theres a tutorial along with it which u hav to watch to set it up. I wish u the best of luck m8.

You should setup a webhook and a discord bot.

The discord bot would have a command e.g. !move [user] [channel_id]
The webhook would say in the server “!move @.user 912339681050492959”

DONT LEAK THE WEBHOOK ID, REGENERATE THE ID NOW BEFORE THEY CAN HACK IT. AND WHENEVER YOU HAVE A CODD THAT CONTAINS A BOT TOKEN OR WEBHOOK ID, censor it. Caps

1 Like