Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Player = game:GetService("Players").LocalPlayer
- local Module
- local CreateChatModule = function(Part)
- local this = {Current = nil}
- local BillboardGui = Instance.new("BillboardGui")
- BillboardGui.Adornee = Part
- BillboardGui.Size = UDim2.new(20, 0, 2, 0)
- BillboardGui.SizeOffset = Vector2.new(0, 1)
- BillboardGui.StudsOffset = Vector3.new(0, 1, 0)
- BillboardGui.Parent = Part
- local Frame = Instance.new("Frame", BillboardGui)
- Frame.BackgroundTransparency = 1
- Frame.Size = UDim2.new(1, 0, 1, 0)
- local Container = Instance.new("Frame")
- Container.Name = "Container"
- Container.BackgroundTransparency = 1
- Container.Size = UDim2.new(1, 0, 1, 0)
- Container.ClipsDescendants = true
- local Message = Instance.new("TextLabel", Container)
- Message.Name = "Message"
- Message.BackgroundColor3 = Color3.new()
- Message.BackgroundTransparency = 0.5
- Message.Size = UDim2.new(1, 0, 1, 0)
- Message.Position = UDim2.new(0, 0, 1, 0)
- Message.Font = Enum.Font.SourceSans
- Message.TextScaled = true
- BillboardGui.Parent = Part
- function this:RemoveChat()
- local Frame = self.Current
- if Frame and Frame:IsDescendantOf(workspace) then
- Frame.Message:TweenPosition(
- UDim2.new(0, 0, -1, 0),
- Enum.EasingDirection.Out,
- Enum.EasingStyle.Sine, 0.5, true
- )
- game.Debris:AddItem(Frame, 0.5)
- self.Current = nil
- end
- end
- function this:AddChat(Text)
- self:RemoveChat()
- local Frame = Container:Clone()
- Frame.Size = UDim2.new(1, 0, #Text > 120 and 1 or 0.5, 0)
- local Message = Frame.Message
- Frame.Name = "Container"
- Frame.Parent = BillboardGui.Frame
- Message.Text = Text
- Frame.Visible = true
- Message:TweenPosition(
- UDim2.new(),
- Enum.EasingDirection.In,
- Enum.EasingStyle.Sine, 0.5, true
- )
- self.Current = Frame
- delay(5, function()
- if self.Current == Frame then
- self:RemoveChat()
- end
- end)
- spawn(function()
- local t = tick()
- while self.Current == Frame do
- wait()
- local currentTime = 5*tick()
- Message.TextColor3 = Color3.new(
- math.sin(currentTime + math.pi),
- math.sin(currentTime + math.pi/2),
- math.sin(currentTime)
- )
- end
- end)
- end
- return this
- end
- local CharacterAdded = function(Character)
- local Head = Character:WaitForChild("Head")
- Module = CreateChatModule(Head)
- end
- if Player.Character then
- CharacterAdded(Player.Character)
- end
- Player.CharacterAdded:connect(CharacterAdded)
- Player.Chatted:connect(function(Message)
- if Player.Character and Player.Character:FindFirstChild("Head") then
- Module:AddChat(Message)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement