Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Expected '}' (to close '{' at line 9), got '[' ?

Asked by 4 years ago

So i am trying to make a discord webhook thingy and the local script freaks out and says: Expected '}' (to close '{' at line 9), got '[' Can some of you fix this?

Localscript:

local WHU = "I will not allow you to make my bot text on my discord server, Also im not that dumb :|"
local httpService = game:GetService("HttpService")
local Players = game:GetService("Players")
local Plr = Players.LocalPlayer
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = replicatedStorage:WaitForChild("Send")

function Click()
    local data = {
        ['content'] = "Player "..Plr.Name.." has sended something!"
        ['embeds'] = [
        ]
        }
    local finalData = httpService:JSONEncode(data)
    remoteEvent:FireServer(WHU, finalData)
end

script.Parent.MouseButton1Click:Connect(Click)

--[[
{
  "content": "Player hasanchik sended something!",
  "embeds": [
    {
      "description": "Hello. This is my final message.",
      "color": 16711680,
      "author": {
        "name": "hasanchik",
        "url": "https://web.roblox.com/users/388243015/profile",
        "icon_url": "https://tr.rbxcdn.com/5dccb86ea2be3852007a91c56f5dc00b/100/100/Avatar/Png"
      },
      "footer": {
        "text": "PlayerId"
      }
    }
  ]
}
--]]
0
Delete the enter at line 11-12, I think the script is thinking You are closing the table with ] ? Nguyenlegiahung 1091 — 4y
0
I do not understand what you just said. hasanchik 49 — 4y

3 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

try

local WHU = "I will not allow you to make my bot text on my discord server, Also im not that dumb :|"
local httpService = game:GetService("HttpService")
local Players = game:GetService("Players")
local Plr = Players.LocalPlayer
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = replicatedStorage:WaitForChild("Send")

function Click()
    local data = {
        ['content'] = "Player "..Plr.Name.." has sended something!"
        ['embeds'] = {}
        }
    local finalData = httpService:JSONEncode(data)
    remoteEvent:FireServer(WHU, finalData)
end

script.Parent.MouseButton1Click:Connect(Click)

honestly i have no clue what this does but you ended the table wrong, this fixes the table part, so it might work

Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Method 1) On lines 11 and 12, you are making a table with [] instead of {}

Method 2) I am pretty sure another method would be to change lines 11 and 12 from this:

['embeds'] = [
]

to this:

['embeds'] = []

You might also need replace [] to {} in method 2.

0
I will try it. hasanchik 49 — 4y
0
It sitll does not work hasanchik 49 — 4y
Log in to vote
0
Answered by 4 years ago

Oof, I forgot to use , .

local WHU = "I will not allow you to make my bot text on my discord server, Also im not that dumb :|"
local httpService = game:GetService("HttpService")
local Players = game:GetService("Players")
local Plr = Players.LocalPlayer
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = replicatedStorage:WaitForChild("Send")

function Click()
    local data = {
        ['content'] = "Player "..Plr.Name.." has sended something!",
        ['embeds'] = [
        ],
        }
    local finalData = httpService:JSONEncode(data)
    remoteEvent:FireServer(WHU, finalData)
end

script.Parent.MouseButton1Click:Connect(Click)

Answer this question