Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function NPCSelection(NPC)
- if InteractingWithNPC == false then
- InteractingWithNPC = true
- local NPCData = NPCsLibrary[NPC]
- local CurrentIndex = 1
- local function UpdateMessage(Index)
- NPCTextBox.NPCText.Text = ""
- for i = 1, #NPCData.Chats[Index].Message do
- NPCTextBox.NPCText.Text = NPCData.Chats[Index].Message:sub(1, i)
- if NPCData.Chats[1].Message:sub(i, i) == " " then
- Sounds.Click:Play()
- end
- if InRadiusWithNPC == false then
- for i = 1,10 do
- NPCTextBox.BackgroundTransparency = NPCTextBox.BackgroundTransparency + 0.07
- NPCTextBox.NPCName.TextTransparency = NPCTextBox.NPCName.TextTransparency + 0.1
- NPCTextBox.NPCName.TextStrokeTransparency = NPCTextBox.NPCName.TextStrokeTransparency + 0.1
- NPCTextBox.NPCText.TextTransparency = NPCTextBox.NPCText.TextTransparency + 0.1
- NPCTextBox.NPCName.Underline.BackgroundTransparency = NPCTextBox.NPCName.Underline.BackgroundTransparency + 0.1
- wait()
- end
- NPCTextBox.NPCName.Text = ""
- NPCTextBox.NPCText.Text = ""
- InteractingWithNPC = false
- return
- end
- wait()
- end
- local PositionIndex = 0
- for i,v in pairs(NPCData.Chats[Index].Options) do
- PositionIndex = PositionIndex + 1
- local OptionButton = Extra.Option:Clone()
- OptionButton.Name = i
- OptionButton.Text = i
- OptionButton.Visible = true
- OptionButton.Parent = NPCTextBox.Buttons
- OptionButton:TweenPosition(UDim2.new(0.01,0,((PositionIndex - 1)*.35) + 0.125), "Out", "Back", 1, true)
- wait(0.35)
- end
- end
- NPCTextBox.Buttons.ChildAdded:Connect(function(Button)
- Button.MouseButton1Click:Connect(function()
- print(CurrentIndex, Button.Name, NPCData.Chats[CurrentIndex].Options[Button.Name])
- if NPCData.Chats[CurrentIndex].Options[Button.Name] ~= "Cancel" then
- for i,v in pairs(NPCTextBox.Buttons:GetChildren()) do
- v:Destroy()
- end
- print(1)
- UpdateMessage(NPCData.Chats[CurrentIndex].Options[Button.Name])
- CurrentIndex = CurrentIndex + 1
- else
- spawn(function()
- for i,v in pairs(NPCTextBox.Buttons:GetChildren()) do
- v:Destroy()
- end
- end)
- for i = 1,10 do
- NPCTextBox.BackgroundTransparency = NPCTextBox.BackgroundTransparency + 0.07
- NPCTextBox.NPCName.TextTransparency = NPCTextBox.NPCName.TextTransparency + 0.1
- NPCTextBox.NPCName.TextStrokeTransparency = NPCTextBox.NPCName.TextStrokeTransparency + 0.1
- NPCTextBox.NPCText.TextTransparency = NPCTextBox.NPCText.TextTransparency + 0.1
- NPCTextBox.NPCName.Underline.BackgroundTransparency = NPCTextBox.NPCName.Underline.BackgroundTransparency + 0.1
- wait()
- end
- NPCTextBox.NPCName.Text = ""
- NPCTextBox.NPCText.Text = ""
- InteractingWithNPC = false
- InRadiusWithNPC = false
- NPCInRadius = ""
- CurrentIndex = 1
- end
- end)
- end)
- UpdateMessage(1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement