Why does the ClickDetector never work?

Hello fellow developers!

I am developing an online school (GE International School)
and now want to open screen GUIs when a student clicks a tablet in the classroon.

Now I have made a ClickDetector and wrote a local script as follows,
only to see nothing is shown when I click the pointer.
I will appreciate if someone point out the cause of the problem.

Code within LocalScripts will only run if it’s a descendant of one of the following objects:

  • A Player’s Backpack , such as a child of a Tool
  • A Player’s Character model
  • A Player’s PlayerGui
  • A Player’s PlayerScripts .
  • The ReplicatedFirst service

In the first screenshot you posted, the “OpenExerciseTest” LocalScript is not a descendant of any of those objects, which means that the code won’t run.

2 Likes

I am not positive, but you might have to write a script for each tablet. (not sure because ive never tried it that way)

Has this way worked for you before? Have you tried it with only one tablet?

If I remembered, you can’t use click detectors with local script. You can only use it with normal script.

Thank you for your quick reply.
I didin’t know above fact.
And so I added the script into another local script in StarterGui (means PlyaerGui)
and found it works now.
(I used Frame.Visible instead of ScreenGui.Enabled)
Thank you again for your useful information.

It works with local scripts, just have to put the script in the right place.

2 Likes

Oh I thought it was already in the startergui based off of your screen shot. Glad you got this worked out!

1 Like

I am planning to prepare multiple tablets in the classroom
and I believe for loop will work for that.
So far I tried with only one tablet, but later I will test with multiple tablets.

Thank you for your reply, but I am afraid I found it works.

It is in fact better to use a local script for this (as ClickDetector instances will still operate) and the player’s PlayerGui instance should only ever be handled locally on the client-side through the use of local scripts.

2 Likes