Advertisement
LawMixer

Don't think about stealing this code, because this is only one part of the code. lmao

Mar 17th, 2021
1,043
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.14 KB | None | 0 0
  1. local Player = game:GetService("Players").LocalPlayer
  2. local Mouse = Player:GetMouse()
  3. local Items = {}
  4. local ValidNames = {
  5.     ["Door"] = true,
  6.     ["Gate"] = true,
  7.     ["Lockdown Door"] = true
  8. }
  9. local InteractionDistance = 15
  10. local CurrentItem = nil
  11. local UI = Player:WaitForChild("PlayerGui"):WaitForChild("InteractionUI")
  12. local TS = game:GetService("TweenService")
  13. local UIS = game:GetService("UserInputService")
  14. local Event = game:GetService("ReplicatedStorage").InteractionEvent
  15. local ClientInteract = true
  16.  
  17. Event.OnClientEvent:Connect(function(State,Response,Item)
  18.     if UI.Primary.TextTransparency ~= 0 then
  19.         TS:Create(UI.Primary,TweenInfo.new(.3,Enum.EasingStyle.Linear),{TextTransparency = 0}):Play()
  20.         TS:Create(UI.Secondary,TweenInfo.new(.3,Enum.EasingStyle.Linear),{TextTransparency = 0}):Play()
  21.     end
  22.     if State == false then
  23.         ClientInteract = false
  24.         UI.Primary.TextColor3 = Color3.fromRGB(200,50,50)
  25.         UI.Secondary.TextColor3 = Color3.fromRGB(200,50,50)
  26.         UI.Primary.Text = "INTERACTION FAILED;"
  27.         UI.Secondary.Text = Response
  28.         for _,Reader in pairs(Item.OtherParts.Readers:GetChildren()) do
  29.             for _,Outline in pairs(Reader.Frame:GetChildren()) do
  30.                 if Outline:IsA("SelectionBox") then
  31.                     Outline.Color3 = Color3.fromRGB(200,50,50)
  32.                 end
  33.             end
  34.         end
  35.         wait(3)
  36.         ClientInteract = true
  37.     else
  38.         ClientInteract = false
  39.         UI.Primary.TextColor3 = Color3.fromRGB(50,200,50)
  40.         UI.Secondary.TextColor3 = Color3.fromRGB(50,200,50)
  41.         UI.Primary.Text = "INTERACTION COMPLETED;"
  42.         UI.Secondary.Text = Response
  43.         for _,Reader in pairs(Item.OtherParts.Readers:GetChildren()) do
  44.             for _,Outline in pairs(Reader.Frame:GetChildren()) do
  45.                 if Outline:IsA("SelectionBox") then
  46.                     Outline.Color3 = Color3.fromRGB(50,200,50)
  47.                 end
  48.             end
  49.         end
  50.         wait(3)
  51.         ClientInteract = true
  52.     end
  53. end)
  54.  
  55. UIS.InputBegan:Connect(function(Input,GPE)
  56.     if Input.UserInputType == Enum.UserInputType.Keyboard and Input.KeyCode == Enum.KeyCode.E and GPE == false and CurrentItem ~= nil and ClientInteract == true then
  57.         Event:FireServer(CurrentItem)
  58.         ClientInteract = false
  59.         wait(1)
  60.         ClientInteract = true
  61.     end
  62. end)
  63.  
  64. for _,Item in pairs(workspace:GetChildren()) do
  65.     if Item:FindFirstChildWhichIsA("BoolValue") and ValidNames[Item:FindFirstChildWhichIsA("BoolValue").Name] then
  66.         Item:FindFirstChildWhichIsA("BoolValue").Value = true
  67.         table.insert(Items,1,Item)
  68.     elseif Item:IsA("Model") or Item:IsA("Folder") then
  69.         for _,SecondCheckItem in pairs(Item:GetChildren()) do
  70.             if SecondCheckItem:FindFirstChildWhichIsA("BoolValue") and ValidNames[SecondCheckItem:FindFirstChildWhichIsA("BoolValue").Name] then
  71.                 SecondCheckItem:FindFirstChildWhichIsA("BoolValue").Value = true
  72.                 table.insert(Items,1,SecondCheckItem)
  73.             end
  74.         end
  75.     end
  76. end
  77.  
  78. spawn(function()
  79.     while wait() do
  80.         if ClientInteract == true then
  81.             if CurrentItem ~= nil then
  82.                 if UI.Primary.TextTransparency ~= 0 then
  83.                     UI.Primary.Text = string.upper(CurrentItem:FindFirstChildWhichIsA("BoolValue").Name).." PROMPT;"
  84.                     UI.Secondary.Text = "Press [E] to interact with the "..CurrentItem:FindFirstChildWhichIsA("BoolValue").Name.."."
  85.                     UI.Primary.TextColor3 = Color3.fromRGB(200,200,200)
  86.                     UI.Secondary.TextColor3 = Color3.fromRGB(200,200,200)
  87.                     TS:Create(UI.Primary,TweenInfo.new(.3,Enum.EasingStyle.Linear),{TextTransparency = 0}):Play()
  88.                     TS:Create(UI.Secondary,TweenInfo.new(.3,Enum.EasingStyle.Linear),{TextTransparency = 0}):Play()
  89.                 end
  90.                 for _,Reader in pairs(CurrentItem.OtherParts.Readers:GetChildren()) do
  91.                     if not Reader.Frame:FindFirstChildWhichIsA("SelectionBox") then
  92.                         local Outline = Instance.new("SelectionBox")
  93.                         Outline.Color3 = Color3.fromRGB(255,255,255)
  94.                         Outline.LineThickness = .02
  95.                         Outline.Transparency = 1
  96.                         Outline.Parent = Reader.Frame
  97.                         Outline.Adornee = Reader.Frame
  98.                         TS:Create(Outline,TweenInfo.new(.15),{Transparency = 0}):Play()
  99.                     end
  100.                 end
  101.                 local Main = CurrentItem.InteractionParts.Interact
  102.                 if (Player.Character.HumanoidRootPart.Position - Main.Position).Magnitude > InteractionDistance or Mouse.Target ~= Main then
  103.                     for _,Reader in pairs(CurrentItem.OtherParts.Readers:GetChildren()) do
  104.                         if Reader.Frame:FindFirstChildWhichIsA("SelectionBox") then
  105.                             spawn(function()
  106.                                 pcall(function()
  107.                                     local Outline = Reader.Frame:FindFirstChildWhichIsA("SelectionBox")
  108.                                     TS:Create(Outline,TweenInfo.new(.15),{Transparency = 1}):Play()
  109.                                     repeat wait() until Outline.Transparency == 1
  110.                                     Outline:Destroy()
  111.                                 end)
  112.                             end)
  113.                         end
  114.                     end
  115.                     CurrentItem = nil
  116.                 end
  117.             else
  118.                 if UI.Primary.TextTransparency ~= 1 then
  119.                     TS:Create(UI.Primary,TweenInfo.new(.1,Enum.EasingStyle.Linear),{TextTransparency = 1}):Play()
  120.                     TS:Create(UI.Secondary,TweenInfo.new(.1,Enum.EasingStyle.Linear),{TextTransparency = 1}):Play()
  121.                 end
  122.                 for _,Item in pairs(Items) do
  123.                     local Main = Item.InteractionParts:WaitForChild("Interact")
  124.                     if (Player.Character:WaitForChild('HumanoidRootPart').Position - Main.Position).Magnitude <= InteractionDistance and Mouse.Target == Main then
  125.                         CurrentItem = Item
  126.                     end
  127.                 end
  128.             end
  129.         end
  130.     end
  131. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement