local chr = owner.Character
local root = chr.HumanoidRootPart
local chatSounds = {}
for i = 1, 6 do
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://5855422149"
sound.Volume = 1.25
table.insert(chatSounds, sound)
end
local chatGui = Instance.new("BillboardGui")
chatGui.Adornee = root
chatGui.Name = "chatText"
chatGui.Size = UDim2.new(2.5, 0, 1.5, 0)
chatGui.StudsOffsetWorldSpace = Vector3.new(0, 5, 0)
local chatText = Instance.new("TextLabel")
chatText.Size = UDim2.new(2.5, 0, 1.5, 0)
chatText.Position = UDim2.new(-0.75, 0, 0.35, 0)
chatText.BackgroundTransparency = 1
chatText.TextTransparency = 1
chatText.TextScaled = true
chatText.TextWrapped = true
chatText.TextColor3 = Color3.new(1, 1, 1)
chatText.TextStrokeColor3 = Color3.new()
chatText.TextStrokeTransparency = 0
chatText.Font = Enum.Font.SourceSans
chatText.Parent = chatGui
owner.Chatted:Connect(function(msg)
if msg:sub(1, 3) == "/e " then
msg = msg:sub(4)
end
for _, v in root:GetChildren() do
if v:IsA("BillboardGui") and v.Name == "chatText" then
v.StudsOffsetWorldSpace = v.StudsOffsetWorldSpace + Vector3.new(0, 2, 0)
end
end
local chtGui = chatGui:Clone()
chtGui.Parent = root
local cht = chatText:Clone()
cht.Parent = chtGui
game:GetService("TweenService"):Create(cht, TweenInfo.new(0.25, Enum.EasingStyle.Circular), {TextTransparency = 0}):Play()
for i = 1, msg:len() do
cht.Text = msg:sub(1, i)
if msg:sub(i) ~= " " then
local talk = chatSounds[Random.new():NextInteger(1, #chatSounds)]
talk.Parent = root
talk:Play()
task.spawn(function()
task.wait(talk.TimeLength)
talk.Parent = nil
end)
end
if msg:sub(i, i) == ", " then
task.wait(0.2)
elseif msg:sub(i, i) == "." or msg:sub(i, i) == "!" or msg:sub(i, i) == "?" then
task.wait(0.5)
else
task.wait()
end
end
game:GetService("Debris"):AddItem(chtGui, 10)
end)