Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local chart = {
- --
- ['a'] = {0,1},
- ['b'] = {1,0,0,0},
- ['c'] = {1,0,1,0},
- ['d'] = {1,0,0},
- ['e'] = {0},
- ['f'] = {0,0,1,0},
- ['g'] = {1,1,0},
- ['h'] = {0,0,0,0},
- ['i'] = {0,0},
- ['j'] = {0,1,1,1},
- ['k'] = {1,0,1},
- ['l'] = {0,1,0,0},
- ['m'] = {1,1},
- ['n'] = {1,0},
- ['o'] = {1,1,1},
- ['p'] = {0,1,1,0},
- ['q'] = {1,1,0,1},
- ['r'] = {0,1,0},
- ['s'] = {0,0,0},
- ['t'] = {1},
- ['u'] = {0,0,1},
- ['v'] = {0,0,0,1},
- ['w'] = {0,1,1},
- ['x'] = {1,0,0,1},
- ['y'] = {1,0,1,1},
- ['z'] = {1,1,0,0},
- --
- ['1'] = {0,1,1,1,1},
- ['2'] = {0,0,1,1,1},
- ['3'] = {0,0,0,1,1},
- ['4'] = {0,0,0,0,1},
- ['5'] = {0,0,0,0,0},
- ['6'] = {1,0,0,0,0},
- ['7'] = {1,1,0,0,0},
- ['8'] = {1,1,1,0,0},
- ['9'] = {1,1,1,1,0},
- ['0'] = {1,1,1,1,1},
- --
- ['.'] = {0,1,0,1,0,1},
- [','] = {1,1,0,0,1,1},
- ['?'] = {0,0,1,1,0,0},
- ['\''] = {0,1,1,1,1,0},
- ['!'] = {1,0,1,0,1,1},
- ['/'] = {1,0,0,1,0},
- [':'] = {1,1,1,0,0,0},
- [';'] = {1,0,1,0,1,0},
- ['='] = {1,0,0,0,1},
- ['+'] = {0,1,0,1,0},
- ['-'] = {1,0,0,0,0,1},
- ['_'] = {0,0,1,1,0,1},
- ['"'] = {0,1,0,0,1,0},
- ['@'] = {0,1,1,0,1,0},
- --
- }
- local function to_morse(str)
- if str and #str >= 1 then else return end
- str = string.gsub(str,' ','.')
- local data = {}
- for i = 1,#str do
- local letter = string.sub(str,i,i)
- local beeps = chart[letter]
- if beeps then
- table.insert(data,beeps)
- end
- end
- return data
- end
- local plr = owner
- local char = plr.Character
- local head = char:FindFirstChild("Head")
- BillboardGui0 = Instance.new("BillboardGui")
- TextBox1 = Instance.new("TextBox")
- BillboardGui0.Parent = head
- BillboardGui0.LightInfluence = 0
- BillboardGui0.Brightness = 2
- BillboardGui0.Size = UDim2.new(8, 0, 3, 0)
- BillboardGui0.Active = true
- BillboardGui0.ClipsDescendants = true
- BillboardGui0.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
- BillboardGui0.SizeOffset = Vector2.new(0, 2)
- TextBox1.Parent = BillboardGui0
- TextBox1.Size = UDim2.new(1, 0, 1, 0)
- TextBox1.BackgroundColor = BrickColor.new("Institutional white")
- TextBox1.BackgroundColor3 = Color3.new(1, 1, 1)
- TextBox1.BackgroundTransparency = 1
- TextBox1.Font = Enum.Font.SourceSans
- TextBox1.FontSize = Enum.FontSize.Size14
- TextBox1.TextColor = BrickColor.new("Institutional white")
- TextBox1.TextColor3 = Color3.new(1, 1, 1)
- TextBox1.TextScaled = true
- TextBox1.TextSize = 14
- TextBox1.TextStrokeTransparency = 0
- TextBox1.TextWrap = true
- TextBox1.TextWrapped = true
- local last_change = 0
- local function change_text(str)
- last_change = os.clock()
- TextBox1.Text = str
- end
- local function change_visible(mode)
- mode = mode or false
- BillboardGui0.Enabled = mode
- end
- local morse_s = head:FindFirstChild('morse_s') or Instance.new("Sound")
- morse_s.Name = 'morse_s'
- morse_s.Volume = 1
- morse_s.Parent = head
- local types = {
- [0] = {
- str = '.',
- sound = 967014073,
- speed = 0.16,
- },
- [1] = {
- str = '-',
- sound = 967014213,
- speed = 0.31,
- },
- }
- local msg_id = 0
- local speed_multi = 2
- local function play_morse(data)
- msg_id += 1
- local cur = msg_id
- local str = ''
- for _,beeps in pairs(data) do
- for _,beep in pairs(beeps) do
- if msg_id == cur then else return end
- local bt = types[beep]
- str = str .. bt.str
- change_text(str)
- local s = morse_s:Clone()
- s.PlayOnRemove = true
- s.SoundId = 'rbxassetid://' .. bt.sound
- s.Volume = 2
- s.Parent = morse_s.Parent
- s:Destroy()
- wait(bt.speed/speed_multi)
- end
- if msg_id == cur then else return end
- str = str .. ' '
- change_text(str)
- wait(0.5/speed_multi)
- end
- end
- local function play_text(str)
- local data = to_morse(str)
- play_morse(data)
- end
- game:GetService("RunService").Stepped:Connect(function()
- if os.clock()-last_change >= 3 then
- change_visible(false)
- else
- change_visible(true)
- end
- end)
- plr.Chatted:Connect(play_text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement