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