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)
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.
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)
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.
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.
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)