Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.97 KB | None | 0 0
  1. --Services
  2. local players = game:GetService("Players")
  3. local uis = game:GetService("UserInputService")
  4. local repStor = game:GetService("ReplicatedStorage")
  5. local run = game:GetService("RunService")
  6. --Vars
  7. local plr = players.LocalPlayer
  8. local char = plr.Character or plr.CharacterAdded:Wait()
  9. local mouse = plr:GetMouse()
  10. local cRF = repStor:FindFirstChildOfClass("RemoteFunction")
  11. local cRE = repStor:FindFirstChildOfClass("RemoteEvent")
  12. local db = false
  13.  
  14. uis.InputEnded:Connect(function(key,gpe)
  15.     if gpe then return end
  16.     if key.UserInputType == Enum.UserInputType.MouseButton1 then
  17.         --if not char and not char:FindFirstChild("Humanoid") then return end
  18.         --char.Humanoid:MoveTo(mouse.Hit.p)
  19.     end
  20. end)
  21. local doors,openDoors = cRF:InvokeServer("Doors"),{}
  22.  
  23. run.RenderStepped:Connect(function()
  24.     for _,v in next, doors do
  25.         if plr:DistanceFromCharacter(v.ProximityDetector.Position) > 10 or char.Humanoid.Sit then
  26.             openDoors[v] = nil
  27.             cRE:FireServer("HingeDoor",v)
  28.             v.DoorHinge.TargetAngle = v.DoorHinge.UpperAngle
  29.         else
  30.             openDoors[v] = true
  31.             cRE:FireServer("HingeDoor",v)
  32.             v.DoorHinge.TargetAngle = v.DoorHinge.LowerAngle
  33.         end
  34.     end
  35. end)
  36.  
  37. local function lerp(part,target)
  38.     if not part or not target or part.Lerping.Value then return end
  39.     part.Lerping.Value = true
  40.     local oldCF = part.CFrame
  41.     for i = 0,1,.1 do
  42.         part.CFrame = oldCF:lerp(target,i)
  43.         run.RenderStepped:Wait()
  44.     end
  45.     part.Lerping.Value = false
  46. end
  47.  
  48. workspace.Chef.Touched:Connect(function(hit)
  49.     if db then return end
  50.     db = true
  51.     local char = hit:FindFirstAncestorOfClass("Model")
  52.     local hum = char and char:FindFirstChild("Humanoid")
  53.     local plr = char and hum and hum.Health > 0 and players:GetPlayerFromCharacter(char)
  54.     if not plr then return end
  55.     local pizza = true
  56.     local cam = workspace.CurrentCamera
  57.     local targetCam = workspace.CameraChef
  58.     local rad1 = math.rad(1)
  59.     cam.CFrame = targetCam.CFrame
  60.     cam.CameraType = Enum.CameraType.Scriptable
  61.     local lastPos = mouse.Hit.p.Z
  62.     coroutine.resume(coroutine.create(function()
  63.         local selection
  64.         run.RenderStepped:Connect(function()
  65.             local diff = (mouse.Hit.p.X - lastPos)/20
  66.             targetCam.CFrame = CFrame.new(-74.6,33,math.clamp(lastPos + diff/5,-15.925,-.525))*CFrame.Angles(0,rad1*-90,0)
  67.             cam.CFrame = cam.CFrame:lerp(targetCam.CFrame,.5)
  68.             local pos = math.clamp(mouse.Hit.p.X,-14.35,1.4)
  69.             workspace.TV:SetPrimaryPartCFrame(CFrame.new(-64.741,33.6,cam.CFrame.p.Z)*CFrame.Angels(0,rad1*90,0))
  70.             lastPos = lastPos + diff/5
  71.             local topping = mouse.Target
  72.             if not topping and not topping:IsDescendantOf(workspace.Toppings) then return end
  73.             if topping ~= selection then
  74.                 if selection then
  75.                     lerp(selection,selection.CFrame*CFrame.new(0,-.2,0))
  76.                 end
  77.                 wait()
  78.                 selection = topping
  79.                 lerp(selection,selection.CFrame*CFrame.new(0,.2,0))
  80.             end
  81.             if selection then
  82.                 lerp(selection,selection.CFrame*CFrame.new(0,-.2,0))
  83.                 selection = nil
  84.             end
  85.         end)
  86.     end))
  87.     repStor.Dough:Clone().Parent = workspace
  88. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement