I want to fix the chat color changer in CloneTrooper1019’s Kool Killer
My problem is that when I select a different chat color, it changes the string value correctly but I don’t know how to make it change the color when the string value changes
function StartChat(player)
repeat wait() until player:WaitForChild("ChatColor")
player.Chatted:connect(function(msg)
if player.Character:findFirstChild("Head") then
game:GetService("Chat"):Chat(player.Character:findFirstChild("Head"),msg,Enum.ChatColor[player.ChatColor.Value])
end
end)
end
game.Players.PlayerAdded:connect(StartChat)
function StartChat(player)
repeat wait() until player:WaitForChild("ChatColor")
player.Chatted:connect(function(msg)
if player.Character:findFirstChild("Head") then
game:GetService("Chat"):Chat(player.Character:findFirstChild("Head"),msg,Enum.ChatColor[player.ChatColor.Value])
end
end)
player.ChatColor.Changed:Connect(function(value)
game:GetService("Chat"):Chat(player.Character:findFirstChild("Head"),msg,Enum.ChatColor[player.ChatColor.Value])
end)
end
game.Players.PlayerAdded:connect(StartChat)
You can use the Changed event to set it whenever the value is changed.
The F in find needs to be capitalized. I didn’t even notice.
function StartChat(player)
repeat wait() until player:WaitForChild("ChatColor")
player.Chatted:connect(function(msg)
if player.Character:FindFirstChild("Head") then
game:GetService("Chat"):Chat(player.Character:FindFirstChild("Head"),msg,Enum.ChatColor[player.ChatColor.Value])
end
end)
end
By any chance, is the code you linked in the thread in a server script while the script to change the chat colour a local script? If yes, is there a remote involved? If no, then there needs to be one. LocalScript changes do not propagate to the server except via a remote or where the client is authoritative, so the server never sees the client change the ChatColor value to a new colour, therefore it stays red.
It’s relatively simple to make, Add a remote event in ReplicatedStorage and add a script in ServerScriptService and put this code in it
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, color)
plr.ChatColor.Value = color
end
Now in your buttons that change the chat color, instead of doing a change for the ChatColor Value, just Fire this Remote and give it the color you want to change it to. If you need more help, you could send me the code that handles those 3 buttons and I could lend more help
I’m glad to be of help! I’m honestly glad I saw this post in my Suggested Topics considering it’s days old and you were probably really hoping for a fix which you now have! If you have anymore issues don’t be afraid to make another post!