Advertisement
InTesting

Vending Machine

Jan 14th, 2019
530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.98 KB | None | 0 0
  1. -- Instructions:
  2. --[[
  3. Any local variables with :
  4.  = LocalPlayer:
  5.     Must be replaced with "owner". So if your local variable is game.Players.LocalPlayer , replace it with owner
  6.  = :GetMouse():
  7.     Remove the variable entirely.
  8.  
  9. then paste this over the desired script
  10. --]]
  11.  
  12. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  13. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  14. do
  15.     print("FE Compatibility code by Mokiros | Translated to FE by iPxter")
  16.     script.Parent = Player.Character
  17.  
  18.     --RemoteEvent for communicating
  19.     local Event = Instance.new("RemoteEvent")
  20.     Event.Name = "UserInput_Event"
  21.     --Fake event to make stuff like Mouse.KeyDown work
  22.     local function fakeEvent()
  23.         local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  24.         t.connect = t.Connect
  25.         return t
  26.     end
  27.     --Creating fake input objects with fake variables
  28.     local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  29.     local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  30.     local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  31.         CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  32.     end}
  33.     --Merged 2 functions into one by checking amount of arguments
  34.     CAS.UnbindAction = CAS.BindAction
  35.  
  36.     --This function will trigger the events that have been :Connect()'ed
  37.     local function te(self,ev,...)
  38.         local t = m[ev]
  39.         if t and t._fakeEvent and t.Function then
  40.             t.Function(...)
  41.         end
  42.     end
  43.     m.TrigEvent = te
  44.     UIS.TrigEvent = te
  45.     Event.OnServerEvent:Connect(function(plr,io)
  46.         if plr~=Player then return end
  47.         if io.isMouse then
  48.             m.Target = io.Target
  49.             m.Hit = io.Hit
  50.         else
  51.             local b = io.UserInputState == Enum.UserInputState.Begin
  52.             if io.UserInputType == Enum.UserInputType.MouseButton1 then
  53.                 return m:TrigEvent(b and "Button1Down" or "Button1Up")
  54.             end
  55.             for _,t in pairs(CAS.Actions) do
  56.                 for _,k in pairs(t.Keys) do
  57.                     if k==io.KeyCode then
  58.                         t.Function(t.Name,io.UserInputState,io)
  59.                     end
  60.                 end
  61.             end
  62.             m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  63.             UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  64.         end
  65.     end)
  66.     Event.Parent = NLS([==[
  67.     local Player = game:GetService("Players").LocalPlayer
  68.     local Event = script:WaitForChild("UserInput_Event")
  69.     local UIS = game:GetService("UserInputService")
  70.     local input = function(io,a)
  71.         if a then return end
  72.         --Since InputObject is a client-side instance, we create and pass table instead
  73.         Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  74.     end
  75.     UIS.InputBegan:Connect(input)
  76.     UIS.InputEnded:Connect(input)
  77.     local Mouse = Player:GetMouse()
  78.     local h,t
  79.     --Give the server mouse data 30 times every second, but only if the values changed
  80.     --If player is not moving their mouse, client won't fire events
  81.     while wait(1/30) do
  82.         if h~=Mouse.Hit or t~=Mouse.Target then
  83.             h,t=Mouse.Hit,Mouse.Target
  84.             Event:FireServer({isMouse=true,Target=t,Hit=h})
  85.         end
  86.     end]==],Player.Character)
  87.     Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  88. end
  89. -- End of FE converter
  90.  
  91.  
  92. print("Q for better accuracy of being a vending machine")
  93. local qKey = false
  94. local char = owner.Character
  95. if char then
  96.     if char.Humanoid.RigType==Enum.HumanoidRigType.R6 then
  97.         if char:FindFirstChildWhichIsA("BillboardGui",true) then
  98.         else
  99.             local bil = Instance.new("BillboardGui",char.Head)
  100.             local TL = Instance.new("TextLabel",bil)
  101.             bil.ExtentsOffsetWorldSpace = Vector3.new(0,5,0)
  102.             bil.Size = UDim2.new({0, 200},{0, 200})
  103.             bil.MaxDistance = 32
  104.            
  105.             TL.BackgroundTransparency = 1
  106.             TL.TextScaled = true
  107.             TL.Text = "Click a button for a snack."
  108.             TL.TextColor3 = Color3.fromRGB(255, 255, 255)
  109.             TL.Font = Enum.Font.Cartoon
  110.             TL.Size = UDim2.new(0, 200,0, 200)
  111.             bil.Size = UDim2.new(0, 200,0, 200)
  112.         end
  113.         local cCh = char:GetChildren()
  114.         local part = Instance.new("Part",char)
  115.         part.CanCollide = false
  116.         part.Anchored = false
  117.         part.Size = Vector3.new(.5,1,.1)
  118.         part.CFrame = CFrame.new(char.Torso.Position) * CFrame.Angles(math.rad(char.Torso.Orientation.X),math.rad(char.Torso.Orientation.Y),math.rad(char.Torso.Orientation.Z)) * CFrame.new(-.75,.5,-.5)
  119.         local weld = Instance.new("WeldConstraint",part)
  120.         weld.Part1 = part
  121.         weld.Part0 = char.Torso
  122.         local part1 = Instance.new("Part",char)
  123.         part1.CanCollide = false
  124.         part1.Anchored = false
  125.         part1.Size = Vector3.new(.4,.4,.1)
  126.         part1.CFrame = CFrame.new(char.Torso.Position) * CFrame.Angles(math.rad(char.Torso.Orientation.X),math.rad(char.Torso.Orientation.Y),math.rad(char.Torso.Orientation.Z)) * CFrame.new(-.75,.75,-.55)
  127.         part1.BrickColor = BrickColor.new("Really red")
  128.         local weld1 = Instance.new("WeldConstraint",part)
  129.         weld1.Part1 = part
  130.         weld1.Part0 = part1
  131.  
  132.         local part2 = Instance.new("Part",char)
  133.         part2.CanCollide = false
  134.         part2.Anchored = false
  135.         part2.Size = Vector3.new(.4,.4,.1)
  136.         part2.CFrame = CFrame.new(char.Torso.Position) * CFrame.Angles(math.rad(char.Torso.Orientation.X),math.rad(char.Torso.Orientation.Y),math.rad(char.Torso.Orientation.Z)) * CFrame.new(-.75,.25,-.55)
  137.         part2.BrickColor = BrickColor.new("Really red")
  138.         local weld2 = Instance.new("WeldConstraint",part)
  139.         weld2.Part1 = part
  140.         weld2.Part0 = part2
  141.  
  142.         if char:FindFirstChildWhichIsA("Shirt") then
  143.             char:FindFirstChildWhichIsA("Shirt"):Destroy()
  144.         end
  145.         if char:FindFirstChildWhichIsA("Pants") then
  146.             char:FindFirstChildWhichIsA("Pants").PantsTemplate = "rbxassetid://2737266197"
  147.         else
  148.             local pants = Instance.new("Pants",char)
  149.             pants.PantsTemplate = "rbxassetid://2737266197"
  150.         end
  151.         if char:FindFirstChildWhichIsA("ShirtGraphic") then
  152.             char:FindFirstChildWhichIsA("ShirtGraphic"):Destroy()
  153.         end
  154.         for i=1, #cCh do
  155.             if cCh[i]:IsA("CharacterMesh") then
  156.                 cCh[i]:Destroy()
  157.             end
  158.         end
  159.         mouse.KeyDown:Connect(function(key)
  160.             if key=="q" then
  161.                 if qKey==false then
  162.                     for i=1, #cCh do
  163.                         if cCh[i].Name=="Left Arm" or cCh[i].Name=="Right Arm" or cCh[i].Name=="Head" then
  164.                             cCh[i].Transparency = 1
  165.                         elseif cCh[i]:IsA("Accessory") then
  166.                             cCh[i].Handle.Transparency = 1
  167.                         end
  168.                     end
  169.                     char.Head.face.Transparency = 1
  170.                     local bil = char.Head:FindFirstChildWhichIsA("BillboardGui")
  171.                     bil.PlayerToHideFrom = owner
  172.                    
  173.                     if bil.TextLabel.Text=="Click a button for a snack." then
  174.                     else
  175.                         bil.TextLabel.Text="Click a button for a snack."
  176.                     end
  177.                    
  178.                    
  179.                     qKey = true
  180.                 else
  181.                     for i=1, #cCh do
  182.                         if cCh[i].Name=="Left Arm" or cCh[i].Name=="Right Arm" or cCh[i].Name=="Head" then
  183.                             cCh[i].Transparency = 0
  184.                         elseif cCh[i]:IsA("Accessory") then
  185.                             cCh[i].Handle.Transparency = 0
  186.                         end
  187.                     end
  188.                     local bil = char.Head:FindFirstChildWhichIsA("BillboardGui")
  189.                     char.Head.face.Transparency = 0
  190.  
  191.                     bil.PlayerToHideFrom = nil
  192.                     qKey = false
  193.                 end
  194.             end
  195.         end)
  196.         char["Body Colors"].LeftArmColor = BrickColor.new("Dark stone grey")
  197.         char["Body Colors"].RightArmColor = BrickColor.new("Dark stone grey")
  198.         local CD = Instance.new("ClickDetector",part1)
  199.         CD.MouseClick:Connect(function(play)
  200.             local tool = Instance.new("Tool",play.Character)
  201.             tool.CanBeDropped = false
  202.             tool.Name = "Sprite Cranberry"
  203.             local part = Instance.new("Part")
  204.             part.Name = "Handle"
  205.             part.Parent = tool
  206.             part.Size = Vector3.new(2,1,2)
  207.             local mesh = Instance.new("SpecialMesh",part)
  208.             mesh.MeshId = "rbxassetid://2605745921"
  209.             mesh.TextureId = "rbxassetid://2605745951"
  210.             mesh.Scale = Vector3.new(1,1,1)
  211.         end)
  212.         local CD2 = Instance.new("ClickDetector",part2)
  213.         CD2.MouseClick:Connect(function(play)
  214.             local tool2 = Instance.new("Tool",play.Character)
  215.             tool2.CanBeDropped = false
  216.             tool2.Name = "Chips"
  217.             local han2 = Instance.new("Part")
  218.             han2.Name = "Handle"
  219.             han2.Parent = tool2
  220.             han2.Size = Vector3.new(2,1,2)
  221.             local mesh2 = Instance.new("SpecialMesh",han2)
  222.             mesh2.MeshId = "rbxassetid://431009042"
  223.             mesh2.TextureId = "rbxassetid://431009057"
  224.             mesh2.Scale = Vector3.new(.1,.1,.1)
  225.         end)
  226.         while true do
  227.             owner.Character.Humanoid.Health = "inf"
  228.             owner.Character.Humanoid.PlatformStand = false
  229.             owner.Character.Humanoid.WalkSpeed = 16
  230.             owner.Character.Humanoid.JumpPower = 50
  231.             owner.Character.Humanoid.MaxHealth = "inf"
  232.             wait(.5)
  233.         end
  234.     else
  235.         print("You need to be R6.")
  236.     end
  237. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement