CollectionService in a nutshell

Got it! That clears a lot up for me. I’ll go ahead and try it now. Thanks for the explanation!

So I tried setting this up with a local script, but can’t get a gui button connected via tags. I am trying this out on a blank baseplate. The structure I am trying to replace is below. This works to print the local player’s name when the button is pressed.

The new structure with CollectionService is:

When I implement this structure, everything is printed (including the last print("Connected), but the button.Activated event does not work. Nothing happens when I press the button. Is this the correct implementation of the CollectionService?

EDIT: Also the ScreenGui is tagged with the TagEditor plugin like this:
image

Well, in that case the CollectionService implementation seems correct and I don’t really see why that could be happening, but definitely check out the button and its properties or try to use other event, maybe adding the function in the same for loop?

Does not look as a CollectionService issue.

1 Like

I see, thanks! I got it to work by just adding a wait(1) at the beginning of the local script. So you’re right, no CollectionService issue.

I found it for you! The local GUIService runs before LocalPlayer. You need to modify your code a little to remove the wait.

Players.LocalPlayer (roblox.com)

1 Like

Thanks! Fixed it with the documentation you linked to. Looks like the text button was loading after the connection was made. I just had to add this line to fix the issue:

game:GetService(‘Players’).LocalPlayer:WaitForChild(‘PlayerGui’):WaitForChild(‘ScreenGui’)

1 Like