Still have questions? Join our Discord server and get real time help.
Log in to vote
0

# ?Expected identifier when parsing expression [

Asked by
uui 25
3 days ago

im making a gui where you can type a brick name, and a text and it displays text on the selected brick using replicated storage.

function click()

local custom = script.Parent.Parent.CustomName.Text

local text = script.Parent.Parent.CustomText.Text
local part = game.Workspace[custom]

local part1 = workspace:FindFirstChild([custom].SurfaceGui)
if part1 then
custom:FindFirstChild("SurfaceGui")
end

game.ReplicatedStorage.SurfaceGui:Clone().Parent = workspace[custom]
game.Workspace[custom].SurfaceGui.TextLabel.Text = text
end

script.Parent.MouseButton1Click:Connect(click)


if you place a gui on a brick more than once, i want it to delete the old one. thats what the findfirstchild is for, then i will remove the first child. error was Expected identifier when parsing expression [ in line 7. its trying to find custom in the workspace. (which is a variable)

### 1 answer

Log in to vote
0
Answered by 3 days ago
Edited 2 days ago

I'm pretty sure that you aren't supposed to use brackets when also using FindFirstChild because they do basically the same thing.

Try this:

function click()

local custom = script.Parent.Parent.CustomName.Text

local text = script.Parent.Parent.CustomText.Text
local part = game.Workspace[custom]

local part1 = workspace:FindFirstChild(custom)

game.ReplicatedStorage.SurfaceGui:Clone().Parent = workspace[custom]
game.Workspace[custom].SurfaceGui.TextLabel.Text = text
end

script.Parent.MouseButton1Click:Connect(click)


Or if the SurfaceGui were to stay, you would do:

function click()

local custom = script.Parent.Parent.CustomName.Text

local text = script.Parent.Parent.CustomText.Text
local part = game.Workspace[custom]

local part1 = workspace:FindFirstChild(custom).SurfaceGui --This is the gui, not the part

game.ReplicatedStorage.SurfaceGui:Clone().Parent = workspace[custom]
game.Workspace[custom].SurfaceGui.TextLabel.Text = text
end

script.Parent.MouseButton1Click:Connect(click)