So this code hasn’t been working only the owner of a group it works and i dont think i have it set like that,
heres the script.
local groupID = 6207547
local gamepass = 0 --44423213
game.Players.PlayerAdded:Connect(function(player)
print(player.Name.." is in the game")
player.CharacterAdded:Connect(function(character)
print(player.Name.. "has been added as a character") -- make sure it was added to char
local groupRank = player:GetRoleInGroup(groupID) -- checks if player is in groip
local clone = script.Rank:Clone() -- clones the textlabel
clone.Parent = character.Head -- puts the text label on players head
clone.Name1.Text = player.Name
clone.RankF.Text = groupRank
local text = script.Rank.Name1 -- what the label will be
local add = 1
local k = 1
local market = game:GetService("MarketplaceService") -- checks market for gamepass
local AFKStatus = {} -- afk script i have in antoher place
local AFKEvent = game.ReplicatedStorage:FindFirstChild("ShowGUI")
if not AFKEvent then
AFKEvent = Instance.new("RemoteEvent")
AFKEvent.Parent = game.ReplicatedStorage
AFKEvent.Name = "AFK | "..groupRank.." "
end
local updateAFK = function(player,enable)
local Main = player.Character:WaitForChild("Head"):WaitForChild("Rank") -- waits for rank to place
local AFKTagT = Main:WaitForChild("RankF")
if enable then
AFKTagT.Visible = true
AFKTagT.Text = "AFK | "..groupRank.." "
else
AFKTagT.Text = groupRank
end
end
AFKEvent.OnServerEvent:Connect(function(player,enable)
AFKStatus[player] = enable
updateAFK(player,enable)
end)
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(Msg)
-- if player.OwnsGamePassAync.market(gamepass) then
if Msg == "@host" or "@Host" then
print("Changing the Text Color b for: "..player.Name)
clone.Name1.TextColor3 = Color3.new(1, 1, 1)
clone.RankF.TextColor3 = Color3.new(1, 1, 1)
else
if Msg == "@pink" or "@Pink" then
print("Changing the Text Color p for: "..player.Name)
clone.Name1.TextColor3 = Color3.new(1, 0.4, 0.952941)
clone.RankF.TextColor3 = Color3.new(1, 0.4, 0.952941)
else
if Msg == "@purple" or "@Purple" then
print("Changing the Text Color p for: "..player.Name)
clone.Name1.TextColor3 = Color3.new(0.654902, 0.168627, 1)
clone.RankF.TextColor3 = Color3.new(0.654902, 0.168627, 1)
else
if Msg == "@rainbow" or "@Rainbow" then
print("Changing the Text Color rainbow for: "..player.Name)
end
end
end
end
end)
end) --Ending the chatted
end) --Ending the characteradded
end) --
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local AFKEvent = ReplicatedStorage:WaitForChild("ShowGUI")
-- {
local GroupId = 0
local GamepassId = 0
local RoleGuiDataColors = {
["@pink"] = Color3.new(1, 0.4, 0.952941),
["@purple"] = Color3.new(0.654902, 0.168627, 1),
["@rainbow"] = {
-- Dont change index or add here only change the values
Color3.new(0.666667, 0, 0),
Color3.new(1, 0.333333, 0),
Color3.new(1, 1, 0),
Color3.new(0, 0.666667, 0),
Color3.new(0, 0, 1),
Color3.new(0.333333, 0, 0.498039),
Color3.new(0.666667, 0, 1)
},
RainbowIsEnabled = false, -- Dont Change
RainbowTransitionTime = 0.25
}
-- }
local function OnPlayerAdded(Player)
print(Player.Name.." is in the game")
local GamepassIsOwned = false
local function OnCharacterAdded(Character)
print(Character.Name.. "has been added as a character")
local GroupRole = Player:GetRoleInGroup()
local RoleGui = script.Rank:Clone()
RoleGui.Parent = Character:WaitForChild("Head")
RoleGui.Name1.Text = Character.Name
RoleGui.RankF.Text = RoleGui
end
local function OnChatted(Message)
--if GamepassIsOwned then
local Character = Player.Character or Player.CharacterAdded:Wait() -- Make sure If player character is there or player is died so CharacterAdded event will wait it to respawn
local Head = Character:WaitForChild("Head")
local RoleGui = Head:FindFirstChild("Rank")
if RoleGui then
if RoleGuiDataColors[Message:lower()] then
print("Changing the Text Color p for:"..Player.Name)
if Message:lower() == "@rainbow" then
RoleGuiDataColors.RainbowIsEnabled = true
local Index = 1
repeat
local Name1Tween = TweenService:Create(RoleGui.Name1, TweenInfo.new(
RoleGuiDataColors.RainbowTransitionTime,
Enum.EasingStyle.Quad
), {TextColor3 = RoleGuiDataColors[Message:lower()][Index]}
)
local RankFTween = TweenService:Create(RoleGui.RankF, TweenInfo.new(
RoleGuiDataColors.RainbowTransitionTime,
Enum.EasingStyle.Quad
), {TextColor3 = RoleGuiDataColors[Message:lower()][Index]}
)
Name1Tween:Play()
RankFTween:Play()
Name1Tween.Completed:Wait()
Index += 1
until
not RoleGuiDataColors.RainbowIsEnabled
else
RoleGuiDataColors.RainbowIsEnabled = false
RoleGui.Name1.TextColor3 = RoleGuiDataColors[Message:lower()]
RoleGui.RankF.TextColor3 = RoleGuiDataColors[Message:lower()]
end
end
end
--end
end
Player.CharacterAdded:Connect(OnCharacterAdded)
Player.Chatted:Connect(OnChatted) -- This is separated inside the CharacterAdded function (i know that the billboard gui and character was there but once the CharacterAdded function run it will be a waste of adding more chatted events)
if Player.Character then -- Checks if the character is there cuz CharacterAdded event wont trigger if character is already there
OnCharacterAdded(Player.Character)
end
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) then
GamepassIsOwned = true
end
end
local function OnAFKEventRequest(Player, IsAFK)
local Character = Player.Character or Player.CharacterAdded:Wait() -- Make sure If player character is there or player is died so CharacterAdded event will wait it to respawn
local Head = Character:WaitForChild("Head")
local RoleGui = Head:FindFirstChild("Rank")
local AFKPrefix = "AFK | "
if RoleGui then
if IsAFK then
RoleGui.RankF.Text = AFKPrefix..RoleGui.RankF.Text
else
RoleGui.RankF.Text = RoleGui.RankF.Text:sub(#AFKPrefix + 1, #RoleGui.RankF.Text)
end
end
end
Players.PlayerAdded:Connect(OnPlayerAdded)
AFKEvent.OnServerEvent:Connect(OnAFKEventRequest) -- This is separated inside the CharacterAdded function (same as the chatted even once the CharacterAdded function run it will be a waste of adding more of this event)