So I am currently trying to add on to a script that I’m working on so if a player has a gamepass (that comes with a nametag) and is a developer, they would get a nametag for said things and it’d slowly switch between the two, but I’m not quite sure on how to do it.
More details are in the code attached and the pictures attached.
Snippet of the code, with explanation.
if Player.Name == "Name" or Player.Name == "Name" or Player.Name == "Name" then -- Name is just a placement for the Player's name.
tagtext = "[DEVELOPER]" -- The tag that they get, that'll be above their username.
tag.TextColor3 = Color3.fromRGB(255, 255, 255) -- The colour of the tag, obviously.
elseif game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, 10906559) then -- This one is for a gamepass, if they own it they get the tag!
tagtext = "[PREMIUM]" -- The tag that they get, that'll be above their username. (again.)
tag.TextColor3 = Color3.fromRGB(146, 166, 255) -- The colour of the tag. (again)
-- It ends then other parts of the script gets added.
Pictures
If you really need the full code, DM me and I’ll send it to you.
Use a while True do loop to repeatedly switch between the 2. Then do wait(time in seconds) to delay the switch.
So here is some pseudo code for this
if player is developer and player owns game pass then
While loop
tagtext = “[DEVELOPER]” – The tag that they get, that’ll be above their username.
tag.TextColor3 = Color3.fromRGB(255, 255, 255) – The colour of the tag, obviously.
wait seconds
tagtext = “[DEVELOPER]” – The tag that they get, that’ll be above their username.
tag.TextColor3 = Color3.fromRGB(255, 255, 255) – The colour of the tag, obviously.
if Player.Name == "Name" or Player.Name == "Name" or Player.Name == "Name" and game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, 10906559) then
while True do
tagtext = "[DEVELOPER]" -- The tag that they get, that'll be above their username.
tag.TextColor3 = Color3.fromRGB(255, 255, 255) -- The colour of the tag, obviously.
wait(5)
tagtext = "[PREMIUM]" -- The tag that they get, that'll be above their username. (again.)
tag.TextColor3 = Color3.fromRGB(146, 166, 255) -- The colour of the tag. (again)
wait(5)
end
end
You could probably do this by comparing both of your if statements together, and putting your code through a loop like the above post stated, although you might need to detect when you want to break the loop:
local MarketService = game:GetService("MarketplaceService")
local DevNames = {
"Owner";
"Developer";
"OtherDeveloper";
}
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
if table.find(DevNames, Player.Name) and MarketService:UserOwnsGamePassAsync(Player.UserId, 10906559) then
while true do
tagtext = "[DEVELOPER]"
tag.TextColor3 = Color3.fromRGB(255, 255, 255)
wait(3)
tagtext = "[PREMIUM]"
tag.TextColor3 = Color3.fromRGB(146, 166, 255)
wait(3)
if Humanoid.Health == 0 then
break
end
end
end
end)
end)
I tried that the whole tag just disappeared, I did try my own methods after but it just gave me the “Developer” tag even though I own the gamepass for the “Premium” tag.
I came up with something like this. Whitelist table holds the player name’s that are developers. Tags table is sort of extra, but I added it so you don’t repeat the color and text parts. UserOwnsGamePassAsync returns a bool indicating if the player owns the pass, so I made that portion a variable so I can easily check if they own the pass when needed.
local MarketplaceService = game:GetService("MarketplaceService")
local Whitelist = {
"Name",
"Name",
"Name"
}
local Tags = {
Developer = {
Text = "[DEVELOPER]",
Color = Color3.fromRGB(255, 255, 255)
},
Premium = {
Text = "[PREMIUM]",
Color = Color3.fromRGB(146, 166, 255)
}
}
local Whitelisted = table.find(Whitelist, Player.Name)
local OwnsPass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, 10906559)
if Whitelisted then
if OwnsPass then
while true do
tagtext = Tags.Developer.Text
tag.TextColor3 = Tags.Developer.Color
wait(3)
tagtext = Tags.Premium.Text
tag.TextColor3 = Tags.Premium.Color
wait(3)
end
else
tagtext = Tags.Developer.Text
tag.TextColor3 = Tags.Developer.Color
end
elseif OwnsPass then
tagtext = Tags.Premium.Text
tag.TextColor3 = Tags.Premium.Color
end
I’m not sure how you’re defining player and stuff so you need to put this where it best fits if you decide to use it.