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

I don't understand what I did wrong when getting an Onclicked error I keep getting unknown global?

Asked by 5 years ago

if script.Parent.MouseButton1Click:Connect(onClicked)then workspace.Part.Transparency = 0.5 end

what did I do wrong in this code

0
for the onClicked FinessinCuban 7 — 5y
0
onclicked isnt a function Fifkee 2017 — 5y

1 answer

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

To connect an event to a part, you don't need to use an if statement, you simply take out the if and then and add an end). You will also need to add a click detector and connect the MouseClick to that instead. That would make your script look like this:

script.Parent.ClickDetector.MouseClick:Connect(function() -- I also took the onClicked out, as you don't need it.
    workspace.Part.Transparency = 0.5
end)

Hope I helped.

0
o n c l i c k e d i s n o t a f u n c t i o n Fifkee 2017 — 5y
0
@Fifkee I'm aware, I blindly assumed they had it connected to a click detector so I just copy and pasted. Thanks for pointing that out though lol cmgtotalyawesome 1418 — 5y
Ad

Answer this question