"The local function is declared but never used"

So I pasted the OnUserInput code into my code, and a red line appeared beneath it. When I clicked on it, it offered to update my language to at least version 7(?), and then when I clicked that, this happened. And the error is

“The local function ‘OnUserInput’ is declared but never used”

AND

“The local function ‘Update’ is declared but never used”

Everything was fine before, and visual studio was already fully up to date.
What is happening?

It looks like you’re declaring OnUserInput within some other body of code, cut and paste it outside the curly brackets with the Update method and see if that fixes your issue.

1 Like

Thanks!

Now this is the issue :upside_down_face:

I’ve fixed it by moving it here.

Can you explain what the problem was? Like why does it have to be inside certain brackets, when the guy in the video said it wasn’t important where it goes?

Thank you!

fixed

It’s because methods cannot exist on their own, they must exist within a class so that’s why it has to be within the first set of brackets the order of the methods is the part that doesn’t matter so you can define update, OnUserInput ect in what ever order you like, however you cannot define a method within a method, so you can’t define OnUserInput within Update. The curly brackets represent the body of a class, method or expression. I hope that helps clear things up!

1 Like

Yeah it does, thanks for your help!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms