How to Set a BillBoard Gui TextColor from a Script?

Im trying to Change the TextColor3 Value using Color3.new(200,176,100) or i also tried from.RGB and from.HSV and none of it works! Im Changing it from a Local Script that fires a remote event that should change the color.

Remote Event Script
local ReplicatedStorage = game:GetService('ReplicatedStorage')
               local Event = ReplicatedStorage:WaitForChild('AFK')

        Event.OnServerEvent:Connect(function(Player, _)
        	         if Player then
                		Player.Character.Head.AFKTag.AFKTValue.TextColor3 = Color3.fromHSV(0,255,170)
                		print(Player.Name..' is Now AFK.')
                		Player.AFK.Value = not Player.AFK.Value
                		Player:LoadCharacter()
                	end
                end)
Local Script for AFK Button
          -- GetService and Other-- 
   
    local ReplicatedStorage = game:GetService('ReplicatedStorage')
    local AFKEvent = ReplicatedStorage:WaitForChild('AFK')
    local epicblur = game.Lighting.Blur
    local player = game.Players.LocalPlayer
    			-- Key Binds -- 
   
    		-- Text & Miscellaneous--
    local Notice = script.Parent.AFK

    AFKB.MouseButton1Click:Connect(function()
     	if  AFKB.Text == 'AFK:OFF' then
    		AFKEvent:FireServer()
    		player.AFK.Value = true
    		Notice.Visible = true
    		AFKB.Text = 'AFK:ON'
    		Notice:TweenPosition(UDim2.new(0.5,0,0.505,0), "Out", "Linear", 1)
    		
    		wait(0.5)
    		epicblur.Enabled = true
    		Notice.Text = 'AFK IN: 1'
    		wait(1)
    		Notice.Text = 'AFK IN: 2'
    		wait(1)
    		Notice.Text = 'AFK IN: 3'
    		wait(1)
    		Notice:TweenPosition(UDim2.new(1.5,0,0.505,0), "In", "Linear", 1)
    		epicblur.Enabled = false
    		Notice.Visible = not Notice.Visible
    	elseif AFKB.Text == 'AFK:ON' then
    		  AFKEvent:FireServer()
    		   Notice.Visible = true
    		   AFKB.Text = 'AFK:OFF'
    		  Notice:TweenPosition(UDim2.new(0.5,0,0.505,0), "In", "Linear", 1)
    		   
    		  wait(0.5)
    		epicblur.Enabled = true
    		Notice.Text = 'AFK OFF: 3'
    		wait(1)
    		Notice.Text = 'AFK OFF: 2'
    		wait(1)
    		Notice.Text = 'AFK IN: 1'
    		wait(1)
    		Notice:TweenPosition(UDim2.new(1.5,0,0.505,0), "In", "Linear", 1)
    		epicblur.Enabled = false
    		Notice.Visible = not Notice.Visible
    	end
    	
    end)        					
Tag Cloner to Players Head
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local AFK = plr.AFK.Value
		
		local cTag = game:GetService("ServerStorage"):WaitForChild("AFKTag"):Clone()
		cTag.Parent = char.Head
		
		if AFK == true then
			cTag.AFKTValue.Text = 'ON'
			cTag.AFKTValue.TextColor3 = Color3.new(255,10,42)
			wait(1)
		elseif AFK == false then
			cTag.AFKTValue.Text = 'OFF'
			cTag.AFKTValue.TextColor3 = Color3.new(255, 10, 42)
			wait(1)
			
			end
		end)
	end)

Are there any errors in the output?

No Errors at All. I Dont Know Why it wouldnt Work.

Try placing a print after each line to see if it is actually getting to the remote and also its Color3.fromRGB with the values your using.

1 Like

the event does fire because it Loads the Character after afk is pressed and when i look on the Server, the players AFK.Value was set from false to true.

Is the AFKTValue a text label?

Yes. It is a Text Label. Is it Suppose to be a TextLabel?

Color3.new() takes values in between 0 and 1. What you are looking for is Color3.fromRGB()

local ReplicatedStorage = game:GetService('ReplicatedStorage')
               local Event = ReplicatedStorage:WaitForChild('AFK')

        Event.OnServerEvent:Connect(function(Player, _)
        	         if Player then
                		Player.Character.Head.AFKTag.AFKTValue.TextColor3 = Color3.fromRGB(0,255,170)
                		print(Player.Name..' is Now AFK.')
                		Player.AFK.Value = not Player.AFK.Value
                		Player:LoadCharacter()
                	end
                end)

ive already tried this but it does not work.

When you do :LoadCharacter, the character essentially respawns, so anything that isn’t a part of the original character is removed. When you do respawn the character, you might want to reattach it each time.

1 Like

Is there a better method to add it to a character head instead of my method, (because everything the character loads it sets the default values)

plr.CharacterAdded:Connect(function(char)
		local AFK = plr.AFK.Value
		local AFK2 = plr.AFK
		local cTag = game:GetService("ServerStorage"):WaitForChild("AFKTag"):Clone()
		cTag.Parent = char.Head

We can move what you did out of the CharacterAdded function, so you can call this same function to add it back on after you load in the character.

local function attach(char) --takes char as the argument
	local AFK = plr.AFK.Value
		local AFK2 = plr.AFK
		local cTag = game:GetService("ServerStorage"):WaitForChild("AFKTag"):Clone()
		cTag.Parent = char.Head
end
plr.CharacterAdded:Connect(attach)

--Assuming the two are on the same script.
  Event.OnServerEvent:Connect(function(Player, _)
        	         if Player then
                		Player.Character.Head.AFKTag.AFKTValue.TextColor3 = Color3.fromRGB(0,255,170)
                		print(Player.Name..' is Now AFK.')
                		Player.AFK.Value = not Player.AFK.Value
                		Player:LoadCharacter()
                        attach(Player.Character)
                	end
                end)

If they are on different scripts, place that function as a ModuleScript and do it like that.

It does not change the Text or the Color…

game.Players.PlayerAdded:Connect(function(plr)
    local function attach(char) --takes char as the argument
    	local AFK = plr.AFK.Value
    		local AFK2 = plr.AFK
    		local cTag = game:GetService("ServerStorage"):WaitForChild("AFKTag"):Clone()
    		cTag.Parent = char.Head
    end

    plr.CharacterAdded:Connect(attach)

    --Assuming the two are on the same script.
    local ReplicatedStorage = game:GetService('ReplicatedStorage')
    local Event = ReplicatedStorage:WaitForChild('AFK')
      Event.OnServerEvent:Connect(function(Player, _)
            	         if Player then
                    		Player.Character.Head.AFKTag.AFKTValue.TextColor3 = Color3.fromRGB(0,255,170)
                    		print(Player.Name..' is Now AFK.')
                    		Player.AFK.Value = not Player.AFK.Value
                    		Player:LoadCharacter()
                            attach(Player.Character)
                    	end
    					end)
                    end)

Move this line to below the attach(Player.Character).

It does not change the Color Still.

EDIT: It Does but it underlays the orinigal Billboard. Is this like Cloneing?

EDIT 2: i removed the attach(Player.Character) Apparently it was not nessacary so it works now!

I’m experiencing a similar issue. I can’t change the colour of a billboard GUI text name.