Basically, there's a custom mod where if I'm able to put my name, and I type something, it'll say Owner behind it. I'm wondering if I could do it for a universal thing, meaning that from a group's standpoint, I can add chat tags behind people's names depending on their rank in the group.
Here's my attempt.
game.Players.PlayerAdded:Connect(function(player) local rank = player:GetRankInGroup(3164314) local tags = Instance.new("IntValue",player) tags.Name = "Tags" local tag1 = {"LukeGabrieI", "Owner", Color3.fromRGB(255,0,0)} local tag2 = {"TreyDP", "Best Friend", Color3.fromRGB(255,255,255)} local tag3 = {"Security", Color3.fromRGB(255,255,0)} local tables = {tag1,tag2,tag3} for i,v in pairs (tables) do if rank == 255 and player.Name == v[1] then local tag = Instance.new("Color3Value",tags) tag.Name = v[2] tag.Value = v[3] elseif rank == 254 and player.Name == v[2] then local tag = Instance.new("Color3Value",tags) tag.Name = v[2] tag.Value = v[3] elseif player:GetRoleInGroup(3164314) == 4 then local tag = Instance.new("Color3Value",tags) tag.Name = v[1] tag.Value = v[2] end end end)
The first two work perfectly, but the last one doesn't work. How would I have it so that these Chat Tags can correlate to the Group Rank?
A previous script I used that included one's rank in the leaderboard worked.
Here's the main part of the script.
local grouprank = Instance.new("StringValue", stats) grouprank.Name = "Rank" local rank = player:GetRoleInGroup(3164314) -- Insert the group ID for whatever group you want ranks displayed for here. if rank ~= 0 then grouprank.Value = rank else grouprank.Value = "Guest" end
I would gladly appreciate if their would be a comment or an answer that can benefit me in my teaching of Lua and its awesome scripts hehe.
Thanks, LukeGabrieI
elseif player:GetRoleInGroup(3164314) == 4 then
should change to elseif player:GetRankInGroup(3164314) == 4 then
. Role is the name, rank is the number. I'd suggest redoing the script overall, but hypothetically, that's how it should work.
If you were instead asking how you'd change it to group rank, let me know.
Thanks,
Explosion
Edit:
From what I can see with what you said, you want the tag to show the group rank.
game.Players.PlayerAdded:Connect(function(player) local role = player:GetRoleInGroup(3164314) local tagcolor = Color3.fromRGB(255,0,0) local tags = Instance.new("IntValue",player) tags.Name = "Tags" local tag = Instance.new("Color3Value",tags) tag.Name = role tag.Value = tagcolor end)
This is the most basic version of what you apparently aim for. If you want different colours, you'll go more along the lines of the original script, but in a style like:
if role == "RoleName" then local tag = Instance.new("Color3Value",tags) tag.Name = role tag.Value = Color3.fromRGB(255,0,0) elseif role == "RoleName2" then local tag = Instance.new("Color3Value",tags) tag.Name = role tag.Value = Color3.fromRGB(250,0,0) end
The tag variable thing that is used in the tutorial seems unneeded and even a bit too extensive when you get into something like group roles.
Anyway, if I still haven't answered, let me know.
Thanks again,
Explosion