Help with group only chat bubble script

Hello,
I am trying to make a script so that only players with a minimum rank in my group, will have a custom bubble chat above their head. The script is a local script in replicated first.
Why isn’t this script working?

local Players = game:GetService("Players") -- Gets the Players service
local ChatService = game:GetService("Chat") -- Gets the Chat service
local GroupSettings = {} -- Ignore this table, it's used in the script

local GroupID = 11236710 -- Place gamepass ID, owners of it will enjoy dark bubble chat

ChatService.BubbleChatEnabled = true -- Enables the bubble chat

local GroupAdminChatSettings = { -- Settings of the person who owns the gamepass [DARK]
	BackgroundColor3 = Color3.fromRGB(0, 0, 0), -- Background Color of their bubble chat
	TextColor3 = Color3.fromRGB(255, 191, 2), -- Text Color of their bubble chat
	TextSize = 16, -- Text size of the text in bubble chat
	Font = Enum.Font.GothamSemibold, -- Font of the text in bubble chat	
}

local Settings = { -- Settings that is applied to every person who doesn't own the gamepass [DEFAULT]
	BackgroundColor3 = Color3.fromRGB(255, 255, 255), -- Background Color of the bubblechat
	TextColor3 = Color3.fromRGB(0, 0, 0), -- Text Color of the bubble chat
	TextSize = 16, -- Text size of the text in bubble chat
	Font = Enum.Font.GothamSemibold, -- Font of the text in bubble chat

	UserSpecificSettings = GroupSettings
}


local function UpdatePlayerBubbleChats()
	-- This function gets all players from game and applies dark chat to them if they own the gameapss

	for i, v in pairs(game.Players:GetChildren()) do
		if Players:GetRankInGroup(GroupID) >= 4 then
			table.insert(GroupSettings, v.UserId, GroupAdminChatSettings)
		end
	end

	game:GetService("Chat"):SetBubbleChatSettings(Settings)
end

game.Players.PlayerAdded:Connect(function()
	UpdatePlayerBubbleChats()
end)


game.Players.PlayerRemoving:Connect(function()
	UpdatePlayerBubbleChats()
end)

pcall(function()
	UpdatePlayerBubbleChats()
end)
1 Like
		if Players:GetRankInGroup(GroupID) >= 4 then
			table.insert(GroupSettings, v.UserId, GroupAdminChatSettings)
		end

shouldnt it be

		if v:GetRankInGroup(GroupID) >= 4 then
			table.insert(GroupSettings, v.UserId, GroupAdminChatSettings)
		end

?

2 Likes

It worked thank you so much, I appreciate the help that has been bugging me all morning!

1 Like

i dont know well about scripting but try this
add a local script to starter player script

local Players = game.Players.LocalPlayer -- Gets the Players service
local ChatService = game:GetService("Chat") -- Gets the Chat service
local GroupSettings = {} -- Ignore this table, it's used in the script

local GroupID = 11236710 -- Place gamepass ID, owners of it will enjoy dark bubble chat

ChatService.BubbleChatEnabled = true -- Enables the bubble chat

local GroupAdminChatSettings = { -- Settings of the person who owns the gamepass [DARK]
	BackgroundColor3 = Color3.fromRGB(0, 0, 0); -- Background Color of their bubble chat
	TextColor3 = Color3.fromRGB(255, 191, 2); -- Text Color of their bubble chat
	TextSize = 16; -- Text size of the text in bubble chat
	Font = Enum.Font.GothamSemibold; -- Font of the text in bubble chat	
}

local Settings = { -- Settings that is applied to every person who doesn't own the gamepass [DEFAULT]
	BackgroundColor3 = Color3.fromRGB(255, 255, 255); -- Background Color of the bubblechat
	TextColor3 = Color3.fromRGB(0, 0, 0); -- Text Color of the bubble chat
	TextSize = 16; -- Text size of the text in bubble chat
	Font = Enum.Font.GothamSemibold; -- Font of the text in bubble chat

	UserSpecificSettings = GroupSettings
}


local function UpdatePlayerBubbleChats()
	-- This function gets all players from game and applies dark chat to them if they own the gameapss

	for i, v in pairs(game.Players:GetChildren()) do
		if Players:GetRankInGroup(GroupID) >= 4 then
			table.insert(GroupSettings, v.UserId, GroupAdminChatSettings)
		end
	end

	game:GetService("Chat"):SetBubbleChatSettings(Settings)
end

game.Players.PlayerAdded:Connect(function()
	UpdatePlayerBubbleChats()
end)


game.Players.PlayerRemoving:Connect(function()
	UpdatePlayerBubbleChats()
end)

pcall(function()
	UpdatePlayerBubbleChats()
end)
2 Likes

So let me explain the code really quick :
so i changed

Players:GetRankInGroup(GroupID) to v:GetRankInGroup(GroupID) because “Players” doesnt have the :GetRankInGroup() function because it doesnt represents a player, it represents the folder where players instances are inserted in.