Issue with Game pass script

I’m trying to make the player’s name (UpperText) flash rainbow colors when they have a certain game pass.

I have no idea what is wrong with the script, if anyone has any suggestions or fixes, please let me know.

Script:

local gamepassId = 8227438
local frame = game.ReplicatedStorage.NameTag.UpperText


game.Players.PlayerAdded:Connect(function(Player)
	if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, gamepassId) then
		while true do
			for hue = 0, 255, 4 do
				frame.TextColor3 = Color3.fromHSV(hue/256, 1, 1)
				frame.TextColor3 = Color3.fromHSV(hue/256, .5, .8)
				wait()
			end
		end
	end
end)

Are there any errors in the output?

1 Like

Nope. My name just shows up red, not rainbow.

image

If I am right, You actually need to reference the Overhead GUI inside of the player character, you are currently referencing to the Replicated Storage’s one, which I believe is not used directly.

2 Likes

But it is in ReplicatedStorage, otherwise I’m afraid I don’t quite understand what you mean.

2 Likes

Im thinking you clone the Billboardgui.

When you clone the Billboardgui, that GUI goes to player head… but when your using local frame = game.ReplicatedStorage.NameTag.UpperText that would only change that GUI not the clones.

Script
local gamepassId = 8227438
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(char)
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, gamepassId) then
local FindGui = char:WaitForChild(“Head”):WaitForChild(“NameTag”)
local Frame = FindGui.UpperText
while true do
for hue = 0, 255, 4 do
frame.TextColor3 = Color3.fromHSV(hue/256, 1, 1)
frame.TextColor3 = Color3.fromHSV(hue/256, .5, .8)
wait()
end
end
end
end)
end)

3 Likes

Ok, seems like you aren’t understanding. So I believe what you are doing is, when Player’s Character is spawned, you add a overhead text GUI to their character head or something and I believe that is where the Overhead GUI is cloned from ReplicatedStorage into the character, so what I meant is you are cloning a new instance of that GUI and putting it inside character and that’s the one you need to run your rainbow Color loop on, but what you are doing currently:

What is happening now: You are basically running a rainbow color loop on the GUI instance in ReplicatedStorage, which will be used for players that join next. But not the player you want to do the rainbow color loop for.

So If you could tell us where the GUI is cloned into the character, then we could figure it out pretty easily.

3 Likes

You had a few problems:

  • You did not get the service marketplace service.
  • You referenced the original name tag, not the one you clone to the players’ head.
  • You did not wait for the character to load.

Here is the updated script:

local gamepassId = 8227438
local MarketplaceService = game:GetService("MarketplaceService")


game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local clone = game.ReplicatedStorage.NameTag:Clone()
		clone.Parent = Character.Head
		local UpperText = clone.UpperText
		if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, gamepassId) then
			while true do
				for hue = 0, 255, 4 do
					UpperText.TextColor3 = Color3.fromHSV(hue/256, 1, 1)
					UpperText.TextColor3 = Color3.fromHSV(hue/256, .5, .8)
					wait()
				end
			end
		end
	end)
end)
2 Likes

this code works and can be a basis for what you want

local gamepassId = 8227438
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if true then --MarketplaceService:UserOwnsGamePassAsync(Player.UserId, gamepassId) then
			local head = character:WaitForChild("Head")
			local billboardGui = Instance.new("BillboardGui")
			billboardGui.Size = UDim2.new(0, 1, 0, 100)
			billboardGui.AlwaysOnTop = true
			local upperText = Instance.new("TextLabel")
			upperText.Text = player.Name
			upperText.AnchorPoint = Vector2.new(0.5, 0.5)
			upperText.BackgroundTransparency = 1
			upperText.Position = UDim2.new(0.5, 0, 0, 0)
			upperText.Size = UDim2.new(1, 0, 1, 0)
			upperText.Parent = billboardGui
			billboardGui.Adornee = head
			wait(1)
			billboardGui.Parent = player:WaitForChild("PlayerGui")
			spawn(function ()
				while upperText.Parent do
					for hue = 0, 255, 4 do
						upperText.TextColor3 = Color3.fromHSV(hue/255, 1, 1)
						--upperText.TextColor3 = Color3.fromHSV(hue/255, .5, .8)
						wait(0.06)
					end
				end
			end)
		end
	end)
end)
3 Likes

Thank you, I thought I was forgetting something. I will remember that. I am still learning

1 Like