View difference between Paste ID: aznM33tv and 8V3JEavy
SHOW: | | - or go back to the newest paste.
1-
__AUTHOR__ = "amazingranma261"
1+
__AUTHOR__ = "Guest537561"
2
local PLAYER = owner
3
local CHARACTER = owner.Character
4
local HEAD = CHARACTER:WaitForChild("Head")
5
local MAX_VIEW_DISTANCE = 30
6
local GUI_HEIGHT = 5
7
local CHAT_BACKGROUND_COLOR = Color3.fromRGB(0,0,0)
8
local CHAT_BACKGROUND_TRANSPARENCY = 1
9
local CHAT_FONT = 1
10
local chatGUIs = {}
11
local s  = Instance.new("Sound", HEAD)
12
s.SoundId = "rbxassetid://418252437"
13
s.Volume = 9e9
14
s.Pitch = 1
15
function updateChatPosition()
16
  for i, v in pairs(chatGUIs) do
17
    v.ExtentsOffsetWorldSpace = v.ExtentsOffsetWorldSpace + Vector3.new(0,1.5,0)
18
  end
19
end
20
21
function createChatBubble(seconds, message)
22
  assert(type(CHAT_FONT) == "number" and CHAT_FONT <17 and CHAT_FONT > -1, "Invalid font value, please enter a number between 0 and 16")
23
  updateChatPosition()
24
25
  local CHAT_GUI = Instance.new("BillboardGui",HEAD)
26
        CHAT_GUI.Adornee = CHAT_GUI.Parent
27
        CHAT_GUI.MaxDistance = MAX_VIEW_DISTANCE
28
    CHAT_GUI.ExtentsOffsetWorldSpace = Vector3.new(0,GUI_HEIGHT,0)
29
        CHAT_GUI.Size = UDim2.new(0,36*(#message/3),0.6,0)
30
    table.insert(chatGUIs, CHAT_GUI)
31
32
    local CHAT_FRAME = Instance.new("Frame",CHAT_GUI)
33
        CHAT_FRAME.Size = UDim2.new(1,0,1,0)
34
        CHAT_FRAME.BackgroundTransparency = CHAT_BACKGROUND_TRANSPARENCY
35
        CHAT_FRAME.BackgroundColor3 = CHAT_BACKGROUND_COLOR
36
37
    local CHAT_TEXT = Instance.new("TextBox",CHAT_FRAME)
38
      CHAT_TEXT.Size = UDim2.new(1,0,1,0)
39
      CHAT_TEXT.TextColor3 = Color3.new(1,1,1)
40
      CHAT_TEXT.TextSize = 20
41
    CHAT_TEXT.MultiLine = true
42
      CHAT_TEXT.Font = CHAT_FONT
43
      CHAT_TEXT.BackgroundTransparency = 1
44
45
    for i = 1,#message do
46
    CHAT_TEXT.Text = string.sub(message,1,i)
47
    s:Play()
48
    
49
    wait()
50
  end
51
  wait(seconds)
52
  table.remove(chatGUIs, 0)
53
    CHAT_GUI:Destroy()
54
  updateChatPosition()
55
end
56
57
58
PLAYER.Chatted:connect(function(msg) coroutine.wrap(createChatBubble)((#msg/5)+2,msg) end)