Name Tags In shop

I already have script of perm name tags when Owner/admins/etc join game and it is already positioned correctly. I want to know if I can sell separate tags using this same script for cash lets say for “noob/chad”
tags. idk how even possible since all the names are written already in script manually to apply their tag…

but I want server to be able to write their name, would I also need a datastore?

script -

local rep = game:GetService("ReplicatedStorage")
local nametag = rep.NameTag 
local groupId = 7435689
local tester = {"Yuenyv", "Lxtiz", "jadensgold", "ellieberries", "MarioPaperPlane", "phant0m_XXX"}

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		
		local head = char.Head
		local newtext = nametag:Clone() 
		local uppertext = newtext.UpperText
		local lowertext = newtext.LowerText
		local humanoid = char.Humanoid
		
		humanoid.DisplayDistanceType = "None"
			
		newtext.Parent = head
		newtext.Adornee = head
		uppertext.Text = player.Name 
		
		
		if player:IsInGroup(groupId) then
			if player.Name ~= "probunny123" and player.Name ~= "CrillicD" then
				if player.MembershipType ~= Enum.MembershipType.Premium then
					lowertext.Text = "GroupMember"
					lowertext.TextColor3 = Color3.fromRGB(0, 255, 0)
					uppertext.TextColor3 = Color3.fromRGB(200, 255, 200)
				end
			end
		end
		if player.MembershipType == Enum.MembershipType.Premium then
			if player.Name ~= "probunny123" and player.Name ~= "CrillicD" then
				for i = 1,tester,1 do
					if player.Name ~= tester[i] then
						lowertext.Text = "Premium"
						lowertext.TextColor3 = Color3.fromRGB(182, 37, 175)
						uppertext.TextColor3 = Color3.fromRGB(252, 144, 215)
						return
					end
				end
			end
		end
		if player.Name == "CrillicD" then
			lowertext.Text = "Owner" 
			lowertext.TextColor3 = Color3.fromRGB(255, 0, 0)
			uppertext.TextColor3 = Color3.fromRGB(245, 116, 116) 
		end
		if player.Name == "probunny123" then
			lowertext.Text = "Admin"
			lowertext.TextColor3 = Color3.fromRGB(255, 255, 0)
			uppertext.TextColor3 = Color3.fromRGB(243, 255, 135)
		end
		
		for i = 1,#tester,1 do
			if player.Name == tester[i] then
				lowertext.Text = "BETA"
				lowertext.TextColor3 = Color3.fromRGB(0, 255, 213)
				uppertext.TextColor3 = Color3.fromRGB(200, 255, 213)
			end
		end			
	end)
end)

do something like this:

local cash = --location of cash
cash.Changed:Connect(function()
if cash.Value < 1000 then
tag.Text = "noob"
elseif cash.Value >= 1000 and < 5500 then
tag.Text = "good"
end
end

this sounds like a solution to get persons balance to auto change their name, or would this still mean if they wanted to buy a tag that part of script would check funds

well, by the way you put it, it seemed you wanted them to just get the tag when they get enough cash. So, for the way you want it, yes you would need a datastore to get the tag they are using. Give me a minute to make the script. Here is the script I made:

local ds = game:GetService("DataStoreService")
local tagdata = ds:GetDataStore("TagData")
local tagexample = game.ServerStorage.Tag

game.Players.PlayerAdded:Connect(function(player)
	local tagstats = tagexample:GetAsync(player.UserId) or {}
	local tag = tagexample:Clone()
	if tagstats then
		tag.Text = tagstats.Text
		tag.TextColor3 = tagstats.TextColor
	else
		tag.Text = "Noob"
		tag.TextColor3 = Color3.fromRGB(255, 51, 10)
	end
	tag.Parent = player --put's in the player so it is easier to save
	tag:Clone().Parent = player.Character.Head --put in the Character's Head
end)

game.Players.PlayerRemoving:Connect(function(player)
	local tagstats = {
		["Text"] = player.Tag.Text,
		["TextColor"] = player.Tag.TextColor3
	}
	tagdata:SetAsync(player.UserId, tagstats)
end)

game:BindToClose(function()
	for i,v in pairs(game.Players:GetPlayers()) do
		local tagstats = {
			["Text"] = v.Tag.Text,
			["TextColor"] = v.Tag.TextColor3
		}
		tagdata:SetAsync(v.UserId, tagstats)
	end
end)

this should work, but if you already have all the tags set up. you can just save the name of the tag and grab it back out of a sort of tag folder when the player joins. If they don’t have a tag saved, you can just put a “noob” tag.

2 Likes