| |
|
| | local Players = game:GetService("Players")
|
| | local TweenService = game:GetService("TweenService")
|
| | local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
| |
|
| | local player = Players.LocalPlayer
|
| | local DialogueEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("DialogueEvent")
|
| |
|
| | local screenGui = Instance.new("ScreenGui")
|
| | screenGui.Name = "DialogueGUI"
|
| | screenGui.ResetOnSpawn = false
|
| | screenGui.Parent = player:WaitForChild("PlayerGui")
|
| |
|
| | local mainFrame = Instance.new("Frame")
|
| | mainFrame.Name = "DialogueFrame"
|
| | mainFrame.Size = UDim2.new(0, 500, 0, 120)
|
| | mainFrame.Position = UDim2.new(0.5, -250, 1, -140)
|
| | mainFrame.BackgroundColor3 = Color3.fromRGB(20, 22, 28)
|
| | mainFrame.BackgroundTransparency = 0.1
|
| | mainFrame.BorderSizePixel = 0
|
| | mainFrame.Visible = false
|
| | mainFrame.Parent = screenGui
|
| |
|
| | local corner = Instance.new("UICorner")
|
| | corner.CornerRadius = UDim.new(0, 12)
|
| | corner.Parent = mainFrame
|
| |
|
| | local stroke = Instance.new("UIStroke")
|
| | stroke.Color = Color3.fromRGB(180, 160, 100)
|
| | stroke.Thickness = 2
|
| | stroke.Parent = mainFrame
|
| |
|
| | local nameLabel = Instance.new("TextLabel")
|
| | nameLabel.Size = UDim2.new(0, 200, 0, 25)
|
| | nameLabel.Position = UDim2.new(0, 10, 0, 5)
|
| | nameLabel.BackgroundColor3 = Color3.fromRGB(120, 100, 50)
|
| | nameLabel.Text = "NPC"
|
| | nameLabel.TextColor3 = Color3.new(1, 1, 1)
|
| | nameLabel.TextScaled = true
|
| | nameLabel.Font = Enum.Font.GothamBold
|
| | nameLabel.Parent = mainFrame
|
| |
|
| | local nameCorner = Instance.new("UICorner")
|
| | nameCorner.CornerRadius = UDim.new(0, 6)
|
| | nameCorner.Parent = nameLabel
|
| |
|
| | local textLabel = Instance.new("TextLabel")
|
| | textLabel.Name = "DialogueText"
|
| | textLabel.Size = UDim2.new(1, -20, 0, 50)
|
| | textLabel.Position = UDim2.new(0, 10, 0, 35)
|
| | textLabel.BackgroundTransparency = 1
|
| | textLabel.Text = ""
|
| | textLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
|
| | textLabel.TextScaled = true
|
| | textLabel.Font = Enum.Font.Gotham
|
| | textLabel.TextXAlignment = Enum.TextXAlignment.Left
|
| | textLabel.TextWrapped = true
|
| | textLabel.Parent = mainFrame
|
| |
|
| | local continueLabel = Instance.new("TextLabel")
|
| | continueLabel.Size = UDim2.new(1, -10, 0, 20)
|
| | continueLabel.Position = UDim2.new(0, 5, 1, -25)
|
| | continueLabel.BackgroundTransparency = 1
|
| | continueLabel.Text = "Click NPC again to continue..."
|
| | continueLabel.TextColor3 = Color3.fromRGB(140, 140, 140)
|
| | continueLabel.TextScaled = true
|
| | continueLabel.Font = Enum.Font.Gotham
|
| | continueLabel.Parent = mainFrame
|
| |
|
| |
|
| | local function typewrite(label, text, speed)
|
| | label.Text = ""
|
| | for i = 1, #text do
|
| | label.Text = string.sub(text, 1, i)
|
| | task.wait(speed or 0.03)
|
| | end
|
| | end
|
| |
|
| | DialogueEvent.OnClientEvent:Connect(function(npcName, line, hasMore)
|
| | nameLabel.Text = " " .. npcName .. " "
|
| | mainFrame.Visible = true
|
| | continueLabel.Text = hasMore and "Click NPC again to continue..." or "End of conversation"
|
| | typewrite(textLabel, line, 0.025)
|
| |
|
| | if not hasMore then
|
| | task.delay(3, function()
|
| | mainFrame.Visible = false
|
| | end)
|
| | end
|
| | end)
|
| |
|