Advertisement
Coded6308

Confirm Purchase LT2

Jun 18th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.02 KB | None | 0 0
  1. --Found by Coded#6308
  2. local player = game.Players.LocalPlayer
  3. local Character = player.Character or game.Players.LocalPlayer.CharacterAdded:wait()
  4. local originWalkSpeed = Character:WaitForChild("Humanoid").WalkSpeed
  5. player.CharacterAdded:connect(function()
  6.     Character = player.Character
  7. end)
  8. wait(1)
  9. local selectButton = require(player:WaitForChild("PlayerGui"):WaitForChild("Scripts"):WaitForChild("SetSelectedButton"))
  10. local PromptChatRemote = game.ReplicatedStorage.NPCDialog.PromptChat
  11. local PlayerChattedRemote = game.ReplicatedStorage.NPCDialog.PlayerChatted
  12. local setChatRemote = game.ReplicatedStorage.NPCDialog.SetChattingValue
  13. local buttomBumper = require(script.Parent.Parent:WaitForChild("BumpButton"))
  14. local NPCDialog = script.Parent:WaitForChild("NPCBillboard")
  15. local UserChat = script.Parent:WaitForChild("Chat")
  16. local PromptUserChat = script.Parent:WaitForChild("PromptChat")
  17. local ChatOptionBackup = UserChat:WaitForChild("Choices"):WaitForChild("ChatChoice")
  18. ChatOptionBackup.Parent = nil
  19. local ChatOptionLineHeight = ChatOptionBackup.Size.Y.Offset
  20. local responses = {}
  21. local responseIndex = 1
  22. local ChattingValue = game.Players.LocalPlayer:WaitForChild("IsChatting")
  23. ChattingValue.Value = 0
  24. local CurrentDialog, SelectedDialog, currentNPC
  25. local yielding = false
  26. function PromptChat(active, NPC, dialog)
  27.     if active and not player.PlayerGui.MouseoverInteractionEngaged.Value and not player.PlayerGui.IsPlacingStructure.Value and not player.PlayerGui.ClientInfoIsOpen.Value and not game.ReplicatedStorage.Notices.ClientNoticeIsOpen.Value then
  28.         setPlatformControls()
  29.         SelectedDialog = dialog or NPC.Dialog
  30.         NPCDialog.Adornee = NPC.Character.Head
  31.         PromptUserChat.PromptText.Text = "Chat with " .. NPC.Name
  32.         setPromptVisibility(dialog == nil)
  33.         currentNPC = NPC
  34.         responseIndex = 1
  35.         setChatting(1)
  36.         if dialog then
  37.             chatSelectionMade()
  38.         end
  39.     elseif not active and currentNPC and currentNPC.Character == NPC.Character then
  40.         CurrentDialog = nil
  41.         SelectedDialog = nil
  42.         setPromptVisibility(false)
  43.         setBillboardVisibility(false)
  44.         setChatOptionsVisibility(false)
  45.         currentNPC = nil
  46.         setChatting(0)
  47.         if not game.Players.LocalPlayer.IsBuyingLand.Value then
  48.             Character.Humanoid.WalkSpeed = originWalkSpeed
  49.             bindJump()
  50.         end
  51.         yielding = false
  52.     end
  53. end
  54. PromptChatRemote.OnClientEvent:connect(PromptChat)
  55. for _, v in pairs({
  56.     player.PlayerGui.MouseoverInteractionEngaged,
  57.     player.PlayerGui.IsPlacingStructure,
  58.     player.PlayerGui.ClientInfoIsOpen,
  59.     game.ReplicatedStorage.Notices.ClientNoticeIsOpen
  60. }) do
  61.     v.Changed:connect(function()
  62.         if v.Value then
  63.             PromptChat(false, currentNPC)
  64.         end
  65.     end)
  66. end
  67. player.PlayerGui.MouseoverInteractionEngaged.Changed:connect(function()
  68.     if currentNPC and player.PlayerGui.MouseoverInteractionEngaged.Value then
  69.         setPromptVisibility(false)
  70.     elseif currentNPC and not player.PlayerGui.MouseoverInteractionEngaged.Value then
  71.         setPromptVisibility(true)
  72.     end
  73. end)
  74. function setChatting(v)
  75.     setChatRemote:InvokeServer(v)
  76. end
  77. setChatting(0)
  78. local lastAdvanceTick
  79. function advanceChat()
  80.     lastAdvanceTick = tick()
  81.     local thisAdvanceTick = lastAdvanceTick
  82.     setBillboardVisibility(false)
  83.     setPromptVisibility(false)
  84.     setChatOptionsVisibility(false)
  85.     if not CurrentDialog then
  86.         PromptChat(false, currentNPC)
  87.         return
  88.     end
  89.     Character.Humanoid.WalkSpeed = 0
  90.     unbindjump()
  91.     setChatting(2)
  92.     wait(0.1)
  93.     if not CurrentDialog then
  94.         if lastAdvanceTick == thisAdvanceTick then
  95.             PromptChat(false, currentNPC)
  96.         end
  97.         return
  98.     end
  99.     NPCDialog.Text.Text = CurrentDialog.ResponseDialog
  100.     setBillboardVisibility(true)
  101.     wait(1.5)
  102.     if not CurrentDialog then
  103.         if lastAdvanceTick == thisAdvanceTick then
  104.             PromptChat(false, currentNPC)
  105.         end
  106.         return
  107.     end
  108.     if ChattingValue.Value == 0 then
  109.         yielding = false
  110.         chatSelectionMade()
  111.         return
  112.     end
  113.     responses = {}
  114.     responseIndex = 1
  115.     local ommitGoodbyeExit = false
  116.     for _, response in pairs(CurrentDialog:GetChildren()) do
  117.         if response:IsA("DialogChoice") then
  118.             local newChoice = {}
  119.             newChoice.DialogObject = response
  120.             newChoice.Button = ChatOptionBackup:clone()
  121.             newChoice.Button.Text = response.UserDialog
  122.             table.insert(responses, newChoice)
  123.         elseif response.Name == "OmmitGoodbyeExit" then
  124.             ommitGoodbyeExit = true
  125.         end
  126.     end
  127.     local firstResponse
  128.     if #responses >= 1 then
  129.         if not ommitGoodbyeExit then
  130.             local exitChoice = {}
  131.             exitChoice.Button = ChatOptionBackup:clone()
  132.             exitChoice.Button.Text = "Goodbye!"
  133.             table.insert(responses, exitChoice)
  134.         end
  135.         UserChat.Position = UDim2.new(0, 100, 1, -80 - 50 * #responses)
  136.         for index, response in pairs(responses) do
  137.             response.Button.Position = UDim2.new(0, 0, 0, (index - 1) * ChatOptionLineHeight)
  138.             response.Button.Parent = UserChat.Choices
  139.             response.Button.MouseButton1Click:connect(function()
  140.                 responseIndex = index
  141.                 SelectedDialog = response.DialogObject
  142.                 chatSelectionMade()
  143.             end)
  144.             firstResponse = firstResponse or response.Button
  145.         end
  146.         selectButton(firstResponse)
  147.         UserChat.Size = UDim2.new(0, UserChat.Size.X.Offset, 0, #responses * ChatOptionLineHeight)
  148.         setChatOptionsVisibility(true)
  149.         chatSelectionScroll(0)
  150.     else
  151.         SelectedDialog = nil
  152.         yielding = false
  153.         chatSelectionMade()
  154.     end
  155.     yielding = false
  156. end
  157. function chatSelectionMade()
  158.     if ChattingValue.Value > 0 and SelectedDialog and not yielding and not player.PlayerGui.MouseoverInteractionEngaged.Value and not player.PlayerGui.IsPlacingStructure.Value and not player.PlayerGui.ClientInfoIsOpen.Value then
  159.         yielding = true
  160.         if not CurrentDialog then
  161.             SelectedDialog = PlayerChattedRemote:InvokeServer(currentNPC, "Initiate") or SelectedDialog
  162.             if not buttomBumper.Bump(PromptUserChat) then
  163.                 return
  164.             end
  165.         else
  166.             SelectedDialog = PlayerChattedRemote:InvokeServer(currentNPC, SelectedDialog.Name) or SelectedDialog
  167.             if responses[responseIndex] and not buttomBumper.Bump(responses[responseIndex].Button) then
  168.                 return
  169.             end
  170.         end
  171.         CurrentDialog = SelectedDialog
  172.         advanceChat()
  173.     elseif ChattingValue.Value > 0 and not yielding then
  174.         if responses[responseIndex] and not buttomBumper.Bump(responses[responseIndex].Button) then
  175.             return
  176.         end
  177.         yielding = true
  178.         CurrentDialog = nil
  179.         SelectedDialog = nil
  180.         if currentNPC then
  181.             PlayerChattedRemote:InvokeServer(currentNPC, "EndChat")
  182.         end
  183.         advanceChat()
  184.     end
  185. end
  186. PromptUserChat.MouseButton1Click:connect(chatSelectionMade)
  187. function chatSelectionScroll(v)
  188.     if ChattingValue.Value == 0 or #responses < 1 then
  189.         return
  190.     end
  191.     responseIndex = responseIndex + v
  192.     if responseIndex < 1 then
  193.         responseIndex = #responses
  194.     elseif responseIndex > #responses then
  195.         responseIndex = 1
  196.     end
  197.     SelectedDialog = responses[responseIndex].DialogObject
  198.     for _, v in pairs(responses) do
  199.         v.Button.Text = " " .. v.Button.Text .. " "
  200.     end
  201. end
  202. function setPlatformControls()
  203.     if input.IsGamePadEnabled() then
  204.         PromptUserChat.PlatformButton.Image = PromptUserChat.PlatformButton.Gamepad.Value
  205.         PromptUserChat.PlatformButton.KeyLabel.Text = ""
  206.     else
  207.         PromptUserChat.PlatformButton.Image = PromptUserChat.PlatformButton.PC.Value
  208.         PromptUserChat.PlatformButton.KeyLabel.Text = "E"
  209.     end
  210. end
  211. local selectedButton = script.Parent.Parent.Scripts.SetSelectedButton.SelectedButton
  212. selectedButton.Changed:connect(function()
  213.     if ChattingValue.Value > 0 and (not selectedButton.Value or not selectedButton.Value:IsDescendantOf(script.Parent)) then
  214.         SelectedDialog = nil
  215.         chatSelectionMade()
  216.     end
  217. end)
  218. function setPromptVisibility(v)
  219.     PromptUserChat.Visible = v
  220. end
  221. function setBillboardVisibility(v)
  222.     NPCDialog.Enabled = v
  223. end
  224. function setChatOptionsVisibility(v)
  225.     UserChat.Visible = v
  226.     if not v then
  227.         for _, response in pairs(UserChat.Choices:GetChildren()) do
  228.             response:Destroy()
  229.         end
  230.     end
  231. end
  232. local contextActionService = game:GetService("ContextActionService")
  233. function bindJump()
  234. end
  235. function unbindjump()
  236. end
  237. wait(1)
  238. input = require(script.Parent.Parent.Scripts.UserInput)
  239. input.InteractSelectionMade(function()
  240.     if ChattingValue.Value == 1 then
  241.         chatSelectionMade()
  242.     end
  243. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement