Code is a LocalScript inside of StarterGui
Code:
local Player = game:GetService("Players").LocalPlayer
local CharacterAdded = Player.Character or Player.CharacterAdded:Wait()
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Died:Connect(function()
local Messages = script.Parent.Messages
local Number = 0
for index, value in pairs(Messages:GetChildren()) do
if value:IsA("StringValue") then
if value.Value ~= nil then
Number +=1
end
end
end
local RandomNum = math.random(1, Number)
local msg = Messages:GetChildren()[Number]
local StarterGui = game:GetService("StarterGui")
repeat
print("HEy!")
wait()
local Success = pcall(function()
StarterGui:SetCore("ChatMakeSystemMessage", {
Text = tostring(msg),
Color = Color3.fromRGB(0, 255, 255),
Font = Enum.Font.SourceSansBold,
TextSize = 18
})
end)
until Success
end)