Help with making a Gui visible when a player is not in a group

I’m currently in the works of making a club, and the requirement is that you need to be in the group to enter the club. They can still join the game and walk around but they can only stay in the main area until they join the group. In order to get them to join the group I made a gui that will only become visible if the player is not in the group. I’m currently having an issue where the gui will stay visible even if a player is in the group.

game.Players.PlayerAdded:Connect(function(newPlayer)
	if newPlayer:IsInGroup(5917382) then                    
		game.StarterGui.NoticeGui:GetChildren("TextLabel").Visible = false
		else 
		game.StarterGui.NoticeGui:GetChildren("TextLabel").Visible = true
	end
end)
1 Like

NewPlayer.PlayerGui not game.StarterGui

game.Players.PlayerAdded:Connect(function(newPlayer)
	if newPlayer:IsInGroup(5917382) then                    
		NewPlayer.PlayerGui.NoticeGui:GetChildren("TextLabel").Visible = false
		else 
		NewPlayer.PlayerGui.NoticeGui:GetChildren("TextLabel").Visible = true
	end
end)

At the moment your editing the UI that would spawn into players PlayerGui by editing StaterGui

Hmm… I’m getting an error that says “NoticeGui is not a valid member of PlayerGui”

1 Like

Is it within a ScreenGui or something? I’m not within your studio I cant tell what’s there.

2 Likes

It’s currently in StarterGui

image

So then its just going before the PlayerGui is fully loaded. Also that Gui is placed everytime player spawns correct?

1 Like

Yes, I’m pretty sure, would I be able to just use game.wait() ?

1 Like

Heres your fix

local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connection(function(Character)
		local PlayerGui = Player:WaitForChild("PlayerGui")
		local NoticeGui = PlayerGui:WaitForChild("NoticeGui")

		if Player:IsInGroup(5917382) then 
			NoticeGui:GetChildren("TextLabel").Visible = false
		else 
			NoticeGui:GetChildren("TextLabel").Visible = true
		end
	end)
end)

Hmm… now I’m getting an error which is… “Workspace.Scripts.GroupAccess:3: attempt to call a RBXScriptSignal value”

It seems “Character” is an unknown global…

1 Like

Also didnt notice… :GetChildren(“TextLabel”) thats quite weird i legit hav no clue how its suppose to work / the outcome :face_with_monocle:

Just do NoticeGui.Visible = True That might work?

yea or .textlabel if you would like then your script should clean and efficient and most importantly working :grin:

local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded(Character)
	local PlayerGui = Player:WaitForChild("PlayerGui")
	local NoticeGui = PlayerGui:WaitForChild("NoticeGui")

	if Player:IsInGroup(5917382) then 
		NoticeGui.Enabled = false
	else 
		NoticeGui.Enabled = true
	end
end)

Player.CharacterAdded(Character) is still shown as an unknown global

Lol forgot to add :connection my bad typo adding it rn . Its added.

--local script that should be patented in what you want to be visible 
script.Parent.Visible = not game.Players.LocalPlayer:IsInGroup(idHere)

copy more times for more textlables

2 Likes