Why isnt this script updating the guis?

I have a bit of really simple code that should disable a gui for some players, but for some reason nothing happens. I added print statement and it prints “running” and the players names so I have no idea why this isn’t working. (This is in a server script)

for i = #gamePlayers, 1, -1 do
	print("running")
	print(gamePlayers[i].Name)
	gamePlayers[i].PlayerGui.MatchResult.Enabled = false
end

Inside starterGui:

image

1 Like

Are you trying to make them unable to use the GUI, or hide it from view? Because if you’re trying to hide it from view then you would use .Visible, which also disables any events from being fired through mouse clicks on the UI (I could be more thorough but I’m running on 0 hours of sleep and am not home atm… idk why I’m on rn LOL)

1 Like

Hahaha, thanks, but this is a screenGui, you can only enabled/disable it. You can’t use the visible property on it.

Yes, I’m trying to disable it so it can’t be seen.

Oh mb, overlooked that. If nobody else assists I’ll see what info I can gather whenever I get home.

1 Like

Try this

 for i = #game.Players:GetChildren(), 1, -1 do
	print("running")
	print(game.Players:GetChildren()[i].Name)
end

Whats this for sorry? I’ve already done print statements and its all perfectly fine. It prints the players names out

It’s been a while since I’ve worked with screen gui since I just set the visibility of a frame or something to false instead, but I think I had the same issues when I did. Have you tried doing it locally? Like sending an event to a local script (Or making the script function out of a local script)

Edit: Just a suggestion. For me it feels kinda random when it decides to work for each, I have a mix of local scripts and a server script to do the UI stuff for my game which was mostly through trial and error
Also I’m home now so I’ll see whether your script works or not for me and if not I’ll see how I can fix it

1 Like

Thank you very much, yeah i find the same thing, editing guis on the server works sometimes and sometimes not, I don’t know why it only works sometimes but I think its better practice to do it on the client anyway so ill do that in the future. I just switched to use remote events and its all working fine. Thank you very much for your help :slight_smile:

I tested as both server and local script and both work. But taking into account you have the script inside the screengui, it should definitely be local anyway, that way it’s not a bunch of server scripts being duplicated amongst every player

1 Like

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