I am currently making a kill feed and the players name is the color of the team they are on. However, I am having this problem where instead of the text changing colors it just shows it like this in the video.
Kill Feed
local players = game:GetService("Players")
local killEvent = game:GetService("ReplicatedStorage"):WaitForChild("KillFeed")
local delete_Txt_After = 5.5
local killedMessages = {
[1] = "whacked",
}
local selfDeathMessages = {
[1] = "Died",
[2] = "slipped on a banana"
}
players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local slippedOnBanana = false
local function onTouchedBananaPeel(otherPart)
local otherCharacter = otherPart.Parent
local otherHumanoid = otherCharacter:FindFirstChildOfClass("Humanoid")
if otherPart:IsA("Part") and otherPart.Name == "BananaPeel" then
if otherHumanoid then
local creatorTag = Instance.new("ObjectValue")
creatorTag.Name = "creator"
creatorTag.Value = players
creatorTag.Parent = otherHumanoid
game.Debris:AddItem(creatorTag, 2)
otherHumanoid.Health = 0
slippedOnBanana = true
killEvent:FireAllClients(otherCharacter.Name, nil, selfDeathMessages[2], delete_Txt_After)
end
end
end
character:WaitForChild("HumanoidRootPart").Touched:Connect(onTouchedBananaPeel)
humanoid.Died:Connect(function()
local creatorTag = Instance.new("ObjectValue")
creatorTag.Name = "creator"
creatorTag.Value = players
creatorTag.Parent = humanoid
game.Debris:AddItem(creatorTag, 5)
local killerTag = humanoid:FindFirstChild("creator")
local killerName = nil
if killerTag and killerTag.Value and killerTag.Value:IsA("Player") then
killerName = killerTag.Value.Name
end
if killerName and killerName ~= plr.Name then
local randomInt = math.random(1, #killedMessages)
local killer = players:FindFirstChild(killerName)
local killerTeamColor = Color3.new(1, 1, 1)
if killer and killer.Team then
killerTeamColor = killer.Team.TeamColor.Color
end
local formattedKillerName = string.format("<font color='#%02X%02X%02X'>%s</font>",
killerTeamColor.R * 255, killerTeamColor.G * 255, killerTeamColor.B * 255, killerName)
killEvent:FireAllClients(plr.Name, formattedKillerName, killedMessages[randomInt], delete_Txt_After)
else
if slippedOnBanana then
killEvent:FireAllClients(plr.Name, nil, selfDeathMessages[1], delete_Txt_After)
else
local randomInt = math.random(1, #selfDeathMessages)
killEvent:FireAllClients(plr.Name, nil, selfDeathMessages[randomInt], delete_Txt_After)
end
end
slippedOnBanana = false
end)
end)
end)
My client
local event = game:GetService("ReplicatedStorage"):WaitForChild("KillFeed")
local mainFrame = script.Parent:WaitForChild("MainFrame")
local text = mainFrame:WaitForChild("ExampleText"):Clone()
local debris = game:GetService("Debris")
local killEvent = game:GetService("ReplicatedStorage"):WaitForChild("KillFeed")
local players = game:GetService("Players")
local player = players.LocalPlayer
mainFrame.ExampleText:Destroy()
local removeTxt = 10
local killFeedFrame = player.PlayerGui:WaitForChild("Kill-Feed"):WaitForChild("MainFrame")
local function CreateText(msg)
local newText = text:Clone()
newText.Name = "Clone"
newText.Text = tostring(msg)
newText.Parent = mainFrame
debris:AddItem(newText, removeTxt)
end
event.OnClientEvent:Connect(function(plr, killer, msg, int)
if killer then
local deathMsg = tostring(msg)
local toWrite = killer .. " " .. deathMsg .. " " .. plr
CreateText(toWrite)
removeTxt = tonumber(int)
else
local deathMsg = tostring(msg)
local toWrite = plr .. " " .. deathMsg
CreateText(toWrite)
removeTxt = tonumber(int)
end
end)