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

Workspace.gold.ClickDetector.Script:15: Expected ')' (to close '(' at line 10), got <eof>??

Asked by 5 years ago

when I click on the brick it does nothing. don't be amazed if there's a lot of errors I'm new.

local door = game.Workspace.door
local boi = false
local goldy = game.Workspace.gold
local sound = script.Parent.Parent:WaitForChild("Shock (A)")


local click = game.Workspace.gold.ClickDetector
click.MaxActivationDistance = 20

script.Parent.MouseClick:Connect(function()
    print("clicked")
    sound:Play()
    door.Transparency = 0.5
    door.CanCollide = false
end

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Because... Sense you are using a :Connect(function(). You need to add a ) at the end of the "end" so your script should be like this:

local door = game.Workspace.door
local boi = false
local goldy = game.Workspace.gold
local sound = script.Parent.Parent:WaitForChild("Shock (A)")


local click = game.Workspace.gold.ClickDetector
click.MaxActivationDistance = 20

script.Parent.MouseClick:Connect(function()
    print("clicked")
    sound:Play()
    door.Transparency = 0.5
    door.CanCollide = false
end) 
0
I'm sorry but I have to downvote this. You don't put a ) preceding the end because you're connecting to an event. You do it to close off the :Connect() call. You do this for any higher-order function call. The function literal body spans multiple lines, the end is part of the function. "end)" is in no way its own thing. programmerHere 371 — 5y
1
The answer is correct. I think you're missing the fact that he said ':Connect(function()' and not just ':Connect(' LucarioZombie 291 — 5y
0
Thanks, it worked! energeticrobux 4 — 5y
Ad

Answer this question