0% found this document useful (0 votes)
37 views3 pages

Gas Station NPC Dialogue Script

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views3 pages

Gas Station NPC Dialogue Script

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Players = game:GetService("Players")


local TweenService = game:GetService("TweenService")
local DialogModule = require([Link])
local p = [Link]
local NPCs = [Link]
local DialogFrame = [Link]
local InputButton = [Link]
local Option1Button = DialogFrame.Option1Button -- Primeiro botão de opção
local Option2Button = DialogFrame.Option2Button -- Segundo botão de opção
local NPCName = [Link]
local image = [Link]

local DIALOG_TWEENINFO = [Link](0.25, [Link],


[Link])

local dialogOpen = false


local dialogTween = nil
local dialogIndex = 0
local gradualTextInProgress = false

-- Função para exibir o texto gradualmente


local function gradualText(text)
if gradualTextInProgress then
return
end

local length = [Link](text)

for i = 1, length, 1 do
gradualTextInProgress = true
[Link] = [Link](text, 1, i)
wait()
end

gradualTextInProgress = false
end

-- Função para lidar com o diálogo


local function onDialog(dialog, index, proximityPrompt)
if dialog[index] then
gradualText(dialog[index])

-- Ativa os botões de resposta quando o diálogo estiver rodando


[Link] = true
[Link] = true

-- Define o texto dos botões a partir do módulo


local responses = DialogModule[[Link]].Responses
[Link] = [Link]
[Link] = [Link]

else
-- Se o diálogo terminar, fecha o painel e libera o jogador
if dialogTween then
dialogTween:Cancel()
dialogTween = nil
end
local tween = TweenService:Create(DialogFrame, DIALOG_TWEENINFO, {
Position = [Link](0, 0, 2, 0)
})
dialogTween = tween
dialogTween:Play()

[Link] = true
dialogOpen = false
dialogIndex = 0
[Link] = false

-- Esconde os botões quando o diálogo acaba


[Link] = false
[Link] = false
end
end

-- Função para terminar o diálogo com a despedida personalizada


local function endDialogWithGoodbye()
local goodbyeMessage = DialogModule[[Link]].Goodbye
[Link] = goodbyeMessage

wait(2) -- Espera 2 segundos antes de fechar o diálogo

-- Fecha o diálogo
if dialogTween then
dialogTween:Cancel()
dialogTween = nil
end
local tween = TweenService:Create(DialogFrame, DIALOG_TWEENINFO, {
Position = [Link](0, 0, 2, 0)
})
dialogTween = tween
dialogTween:Play()

-- Libera o jogador
NPCs[[Link]].[Link] = true
dialogOpen = false
dialogIndex = 0
[Link] = false

-- Esconde os botões ao encerrar o diálogo


[Link] = false
[Link] = false
end

-- Lida com o primeiro botão de resposta


Option1Button.MouseButton1Click:Connect(function()
local response = DialogModule[[Link]].[Link]
[Link] = response

wait(2) -- Mostra a resposta por 2 segundos


endDialogWithGoodbye()
end)

-- Lida com o segundo botão de resposta


Option2Button.MouseButton1Click:Connect(function()
local response = DialogModule[[Link]].[Link]
[Link] = response
wait(2) -- Mostra a resposta por 2 segundos
endDialogWithGoodbye()
end)

-- Lida com o início do diálogo


for _, NPC in pairs(NPCs:GetChildren()) do
wait(0.1)
local humanoidRootPart = NPC:FindFirstChild("HumanoidRootPart")
local proximityPrompt = humanoidRootPart:FindFirstChild("ProximityPrompt")

if humanoidRootPart and proximityPrompt then


[Link] = [Link]
[Link] = "Chat with " .. [Link]

local dialog = DialogModule[[Link]].Dialog

[Link]:Connect(function()
if dialogOpen then
return
end

dialogOpen = true
[Link] = false
[Link] = [Link]
[Link] = true
[Link] = NPCs[[Link]].[Link]
if dialogTween then
dialogTween:Cancel()
dialogTween = nil
end
local tween = TweenService:Create(DialogFrame, DIALOG_TWEENINFO,
{
Position = [Link](0, 0, 1, 0)
})
dialogTween = tween
dialogTween:Play()

dialogIndex = 1
onDialog(dialog, dialogIndex, proximityPrompt)
end)
end
end

You might also like