Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Values = ReplicatedStorage:WaitForChild("Values")
- local Message = Values:WaitForChild("Message")
- local Speaker = Values:WaitForChild("Speaker")
- local Player = game.Players.LocalPlayer
- local DialogueFrame = Player.PlayerGui:WaitForChild("DialogueGui").DialogueFrame
- local viewportCamera = Instance.new("Camera", DialogueFrame.PlayerImage.Icon)
- local RunService = game:GetService('RunService')
- -- Variables
- DefaultMessageDelayTime = 4
- LetterInvertal = 0.05
- MessageWaitSigns = {',', '?', '.'}
- MessageWaitSignDelay = 1
- function playSound(sound_id) -- Plays typing sound
- local sound = Instance.new("Sound",game.ReplicatedStorage)
- sound.SoundId = sound_id
- sound.Volume = .1
- sound.PlayOnRemove = true
- sound:Destroy()
- end
- local function Animate(Text, MessageDelayTime)
- for i = 1,#Text,1 do
- DialogueFrame.Dialogue.Text = string.sub(Text,1,i)
- playSound("rbxassetid://915576050")
- for _, L in pairs(MessageWaitSigns) do
- if string.sub(Text,i,i) == L then
- wait(MessageWaitSignDelay)
- end
- end
- wait(LetterInvertal)
- end
- if tonumber(MessageDelayTime) ~= nil then
- wait(MessageDelayTime)
- else
- wait(DefaultMessageDelayTime)
- end
- DialogueFrame:TweenPosition(UDim2.new(0.55, 0, -1, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quad, 1)
- end
- local function updateCharacter(character)
- for i, v in pairs(DialogueFrame.PlayerImage.Icon.Character:GetDescendants()) do
- v:Destroy()
- end
- for i, v in pairs(character:GetChildren()) do
- if v:IsA("BasePart") or v:IsA("Accessory") or v:IsA("Shirt") or v:IsA("Pants") or v:IsA("ShirtGraphic") or v:IsA("BodyColors") or v:IsA("Humanoid") then
- local new = v:Clone()
- new.Parent = DialogueFrame.PlayerImage.Icon.Character
- if v:IsA("Humanoid") then
- new.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
- end
- end
- end
- DialogueFrame.PlayerImage.Icon.CurrentCamera = viewportCamera
- viewportCamera.CFrame = character.PrimaryPart.CFrame * CFrame.new(0, 1.5, -2.25) * CFrame.Angles(0, math.rad(180), 0)
- end
- Message:GetPropertyChangedSignal("Value"):Connect(function()
- DialogueFrame:TweenPosition(UDim2.new(0.55,0,0.15,0), Enum.EasingDirection.In, Enum.EasingStyle.Quad, 1)
- Animate(Message.Value)
- end)
- Speaker:GetPropertyChangedSignal('Value'):Connect(function()
- print("New Speaker: "..Speaker.Value)
- updateCharacter(workspace[Speaker.Value])
- DialogueFrame.PlayerImage.Icon.nameLabel.Text = Speaker.Value
- end)
Advertisement
Add Comment
Please, Sign In to add comment