Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

what did I do wrong in this code

2 comments

0

for the onClicked

0

onclicked isnt a function

1 answer

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.

2 comments

0

o n c l i c k e d i s n o t a f u n c t i o n

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

This discussion is preserved as it was. New answers, comments, and votes are closed.