GUI enable isn't working view scripts

Hello, I want to make it so if someone is in the AAC group, then they will be able to see the GUI, otherwise if they are not in the group then they won’t be able to see it.

I don’t know what’s the issue but it seems like It’s just not working.
The script is down below if you know why this is isn’t working,

I have already checked for errors and the location of the GUI, but I could not find the problem.

local AACgroup = 12938223

game.Players.PlayerAdded:Connect(function(player)
	if player:IsInGroup(AACgroup) then 
		script.Parent.Parent.Visible = true
	end
end)
1 Like

Is it in local script? If it is, Try to do:

local AACgroup = 12938223

local player = game.Players.LocalPlayer

if player:IsInGroup(AACgroup) then 
	script.Parent.Parent.Visible = true
end
2 Likes

Try writing this script into client since this yielding function has a different cache between server and client as said on the API Reference. Player:IsInGroup

2 Likes

Yes it worked, thanks, although I don’t know what was the problem with it, now I understand why it wasn’t working, so thanks.

1 Like

Uh, maybe try marking Leo’s post as the solution instead of yours?

Yea, sorry I thought I clicked on his post but it was mine,