Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Tavern Interaction
- local NPCs = workspace:WaitForChild("NPCs")
- local Storage = game:GetService("ReplicatedStorage")
- local Players = game:GetService("Players")
- local RS = game:GetService("RunService")
- local UIS = game:GetService("UserInputService")
- local TS = game:GetService("TweenService")
- local Modules = Storage:WaitForChild("Modules")
- local TavernNPCs = NPCs:WaitForChild("TavernNPCs")
- local SpringModule = require(Modules.Utils.spr)
- local Typewriter = require(Modules.Utils.Typewrite)
- local Player = Players.LocalPlayer
- local Char = Player.Character or Player.CharacterAdded:Wait()
- local PrimaryPart = Char:WaitForChild('HumanoidRootPart')
- local NPCStorage = {};
- local canInteract = true
- local function getAmount(dict)
- local i = 0
- for index,value in pairs(dict) do
- i += 1
- end
- return i
- end
- UIS.InputBegan:Connect(function(input, gpe)
- if gpe then return end
- if input.KeyCode == Enum.KeyCode.E then
- if canInteract == false then return end
- if getAmount(NPCStorage) == 0 then
- return;
- else
- if getAmount(NPCStorage) == 1 then
- for index,values in pairs(NPCStorage) do
- canInteract = false
- local NormalJump = Char.Humanoid.JumpPower
- Char.Humanoid.JumpPower = 0
- local bv = Instance.new("BodyVelocity", PrimaryPart)
- bv.Name = 'InteractionDialogue'
- bv.MaxForce = Vector3.new(999999,999999,999999)
- bv.Velocity = Vector3.new(0,0,0)
- Char.Humanoid.AutoRotate = false
- warn("Interact with ".. index.. ' | Hierarchy: '.. values:GetFullName().. ' | Quest Type: '.. values.NPCInfo.QuestType.Value..' Quest')
- local cam = workspace.CurrentCamera
- cam.CameraType = Enum.CameraType.Scriptable
- local tween = TS:Create(workspace.CurrentCamera, TweenInfo.new(0.7), {CFrame = values.CamPart.CFrame})
- tween:Play()
- script.Parent.TavernUI.Main.NPCName.Text = values.Head.Display.NPCName.Text
- script.Parent.TavernUI.Main.Role.Text = values.Head.Display.TitleName.Text
- SpringModule.target(script.Parent.TavernUI.Main, 1, 1.6, {
- Position = UDim2.fromScale(0, 0.823),
- })
- wait(0.5)
- -- change dialogue later
- Typewriter.typeWrite(script.Parent.TavernUI.Main.DialogueText, "Hey there! I'm Mitsuki. I need some help, do have a moment?")
- wait(0.5)
- local textTween1 = TS:Create(script.Parent.TavernUI.Main.Interact, TweenInfo.new(0.5), {TextTransparency = 0, TextStrokeTransparency = 0.7})
- textTween1:Play()
- Typewriter.typeWrite(script.Parent.TavernUI.Main.Interact , "Sure, what happened?")
- local textTween2 = TS:Create(script.Parent.TavernUI.Main.Goodbye, TweenInfo.new(0.5), {TextTransparency = 0, TextStrokeTransparency = 0.7})
- textTween2:Play()
- Typewriter.typeWrite(script.Parent.TavernUI.Main.Goodbye , "Sorry, I'm a bit busy right now!")
- local yesCon;
- local noCon;
- local yesHover1;
- local noHover1;
- local yesHover2;
- local noHover2;
- yesHover1 = script.Parent.TavernUI.Main.Interact.MouseEnter:Connect(function()
- script.Parent.TavernUI.Main.Interact.TextColor3 = Color3.fromRGB(255,255,153)
- end)
- noHover1 = script.Parent.TavernUI.Main.Interact.MouseLeave:Connect(function()
- script.Parent.TavernUI.Main.Interact.TextColor3 = Color3.fromRGB(255,255,255)
- end)
- yesHover2 = script.Parent.TavernUI.Main.Goodbye.MouseEnter:Connect(function()
- script.Parent.TavernUI.Main.Goodbye.TextColor3 = Color3.fromRGB(255,255,153)
- end)
- noHover2 = script.Parent.TavernUI.Main.Goodbye.MouseLeave:Connect(function()
- script.Parent.TavernUI.Main.Goodbye.TextColor3 = Color3.fromRGB(255,255,255)
- end)
- yesCon = script.Parent.TavernUI.Main.Interact.MouseButton1Click:Connect(function()
- end)
- noCon = script.Parent.TavernUI.Main.Goodbye.MouseButton1Click:Connect(function()
- yesCon:Disconnect()
- noCon:Disconnect()
- yesHover1:Disconnect()
- noHover1:Disconnect()
- yesHover2:Disconnect()
- noHover2:Disconnect()
- local tween1 = TS:Create(script.Parent.TavernUI.Main.Interact, TweenInfo.new(0.5), {TextTransparency = 1, TextStrokeTransparency = 1})
- local tween2 = TS:Create(script.Parent.TavernUI.Main.Goodbye, TweenInfo.new(0.5), {TextTransparency = 1, TextStrokeTransparency = 1})
- tween1:Play()
- tween2:Play()
- tween2.Completed:Wait()
- script.Parent.TavernUI.Main.Interact.TextColor3 = Color3.fromRGB(255,255,255)
- script.Parent.TavernUI.Main.Goodbye.TextColor3 = Color3.fromRGB(255,255,255)
- Typewriter.typeWrite(script.Parent.TavernUI.Main.DialogueText, "Oh okay. It was worth a try!")
- wait(0.2)
- SpringModule.target(script.Parent.TavernUI.Main, 1, 1.6, {
- Position = UDim2.fromScale(0, 1.1),
- })
- cam.CameraType = Enum.CameraType.Custom
- bv:Destroy()
- Char.Humanoid.JumpPower = NormalJump
- Char.Humanoid.AutoRotate = true
- coroutine.resume(coroutine.create(function()
- wait(2)
- canInteract = true
- script.Parent.TavernUI.Main.DialogueText.Text = ''
- script.Parent.TavernUI.Main.Goodbye.Text = ''
- script.Parent.TavernUI.Main.Interact.Text = ''
- script.Parent.TavernUI.Main.Interact.TextColor3 = Color3.fromRGB(255,255,255)
- script.Parent.TavernUI.Main.Goodbye.TextColor3 = Color3.fromRGB(255,255,255)
- end))
- end)
- end
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment