Do something when StarterGui:GetCore("ChatActive") was changed

I cant find ANYTHING to update visibility of my custom chat along with the core ChatActive, because GetCore only does it once…
That leads up to using loops
A terrible solution which is a no for me.

This is a pain im dealing with for a month now.
Yes i did go through devforums, and yes i found nothing related besides some bandage fix slaps that only work for PC users.

(Like doing it on a slash key and all that… Surely console/mobile players will magically be able to press the slash key right? And surely no one in their life would click on chat button instead hm??)

I even asked several AI CHATBOTS of all things as my last resort and STILL its left unsolved.

Simply doing something like this will only print the time the local was set, meaning i gotta do GetCore another time to find out the change happened.

local ChatActive = game:GetService("StarterGui"):GetCore("ChatActive")

while true do
	task.wait(0.2)
	print(ChatActive)
end

And here’s my current loop implementation, i need something that wouldn’t be a loop since that just affects performance. Which is why im here overall making this post.

local lastChatState = StarterGui:GetCore("ChatActive")
local function updateGUI()
	local currentChatState = StarterGui:GetCore("ChatActive")
	if currentChatState ~= lastChatState then
		MainGUI.Enabled = currentChatState
		lastChatState = currentChatState
	end
end

task.spawn(function()
	while true do
		updateGUI()
		task.wait(0.050)
	end
end)

What do i need?

  • A proper way to detect ChatActive changes without relying on loops.
  • No RenderStepped, Heartbeat, or any other loop-based approach.
  • Removing the default chat icon and replacing it with a custom one is not an option. (Could be if its really impossible otherwise though.)
  • I’m looking for a signal-based solution (If one even exists, i’d like to also hear a straightforward “no” if its really not possible).

Fire a BindableEvent when you use SetCore and pass what you set it to

I cant simply check when i use SetCore.
What i’ve meant by all this is the standard ways of firing, like clicking on the button itself, using the button from console menu. All that is a CoreGui part that i cannot check.=

Nvm, i think i misunderstood, srryyyy!!!

2 Likes

Here’s the thing. I don’t.
I get what you mean by doing a bindable near SetCore, but i haven’t used it at all in my scripts.
So tracking changes is gonna be done from CoreGui which cant be accessed to normal users, which is why i have to use StarterGui:GetCore()

Ah its alright, atleast you tried helping ^ - ^

1 Like

I think using a bool value and changing its value constantly rather than firing the function constantly is better, so you could try

while task.wait() do
    BoolValue.Value = game.StarterGui:GetCore("ChatActive")
end

and connect to .Changed on that instance

BoolValue.Changed:Connect(function(ChatActive)
    --thing
end)
1 Like

Do you need to disable the chat and enable the custom chat, if I’m not mistaken?

Original chat and all that is already disabled obviously.
What i need is simply update visibility of custom chat when ChatActive was changed to either true or false

That does a loop, which is said as a no in the post.
It kinda bugs with performance. A little, but noticeable enough.

1 Like

This is not possible, CoreGui cannot be accessed and no services expose this functionality. You should create your own button and connect a listener to it, or use a loop.

2 Likes

Obvious!
Which is why im searching for some kinda signal based approach.
Not directly a signal of course, since ChatActive is not a property, but something!
Thats quite stupid if there’s no way to check when a GetCore part was changed.

I mean, there’s a way, it’s just the one way you said we couldn’t suggest. If you want this as a feature, make a feature request.

2 Likes

But yeahh im gonna search for ways before having to stick to those both bandage solutions.
Thanks for help though!

1 Like

Your best option is to replace the original button with a custom one. (even though you said it wasn’t an option)

1 Like

What i’ve meant is… Its a bandage fix, i would only get to doing it if there’s really no main way i wanted it to be. It is applicable! But not what i was aiming for.
I even mentioned those in the original main post.
(In short, just a last resort if nothing is found. Prolly gonna take a day or two before closing. Maybe someone finds a way.)

1 Like

There really is no way to track this through signals, since Roblox does not want scripts to have direct read access to the core gui and does not provide a signal for this use case.

I suggest not using a while true loop though, and instead use a RenderStepped. The while true should be on every devs ‘no no’ list in my opinion.

Also, the if statement above is not needed. if you try to set a property to what it already is set to, Roblox does nothing. After stress testing it, I have come to the conclusion that it does not affect performance. This is just a picky thing that would allow the code to be cleaner.

I would just change it to :

MainGUI.Enabled = StarterGui:GetCore("ChatActive")

I would accept the bandage fix or make a feature request as others have already stated. There is no other way. I mean, if Roblox does not let us directly access the objects that these properties would be located, and doesn’t provide us an event signal to connect to, how could we possible set up a signal connection?

And if this loop somehow causes performance issues for a game, that wouldn’t be the loops fault.

I would chase efficiency in other areas that can have a much greater effect on performance .

2 Likes

Agh, fine on then. Will do. Had to make sure that there would be a better way!
Will do a feature request though, thanks for taking your time guys!