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

ClickDetector MouseClick not working when running server?

Hi,

I'm working on a game where the user clicks on certain objects, modals appear. I have it working when, in Roblox Studio, I choose "Play" or "Play Here". However, when I choose to "Start" a "Local Server", the modals do not appear when clicking on those objects.

Here's the code I am using to make a modal appear:

function onClicked(player) player.PlayerGui.GameConsoleGui.WelcomeModal.Enabled = true end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

The modals are ScreenGui objects that have "Enabled" set to false by default, and only have "Enabled" set to true by scripts.

Appreciate any help with this.

1 comment

0

The server cannot access PlayerGui. Also it's Connect not connect.

1 answer

You cannot access PlayerGui elements and edit them via a Script. You must use a local script. Just clone a local script to the player and have it run the function, and then have the script remove itself.

Have the server sided script as is, but clone a local script.

Have a client script that runs the code

wait(1)
player.PlayerGui.GameConsoleGui.WelcomeModal.Enabled = true
wait(0.1)
script:Destroy()

4 comments

0

Thank you. I think I understand. Could you elaborate a little on how a server can clone a local script to a client?

0
0

Awesome, thank you. Now that I have a better understanding of my original problem, I'm thinking it might just be easier if I use a LocalScript to do client-side detection that the object was clicked, and open the modals that way? There's no real need for me to involve the server in this transaction, is there?

0

Yep, I was able to get it to work with it all just LocalScripts. No need to involve the server. Thanks!

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