Why does this error keep appearing?

I am working on a rank colour changing gamepass, so you press a button and the colour of the rank will change.

The problem is that apparently the Frame that is the parent of the overhead rank labels isn’t there.

I have tried using WaitForChild but nothing is working.

This is the script:

script.Parent.MouseButton1Click:Connect(function(Player)
	local name = script.Parent.Parent.Parent.Parent.Parent.Name 
	print("RankColourUIName = ".. name)
	local Frame = workspace.name.Rank.Frame
	
	Frame.TextLabel.TextColor3 = Color3.new(255, 0, 0)
	Frame.Name1.TextColor3 = Color3.new(255, 0, 0)
end)

image

1 Like

Fixed it for you:

script.Parent.MouseButton1Click:Connect(function(Player)
	local name = script.Parent.Parent.Parent.Parent.Parent.Name 
	print("RankColourUIName = ".. name)
	local Frame = workspace:WaitForChild(name).Rank.Frame
	
	Frame.TextLabel.TextColor3 = Color3.new(255, 0, 0)
	Frame.Name1.TextColor3 = Color3.new(255, 0, 0)
end)

Try using WaitForChild.

By the way, this needs to be Color3.fromRGB or you won’t get the color you want.

1 Like

This works now, thanks! (30 chars)

Why use .fromRGB…? Color3.new works just fine for me.

Color3.new takes values between 0 and 1.

255 is a RGB value.

The colour appears as it should, but I’ll use .fromRGB just incase it doesn’t if I do other colours.