TheUnknownDiscord

Viewport Camera

Sep 8th, 2021 (edited)
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local part1 = Instance.new("Part", game.Workspace)
  2. local part6 = Instance.new("Part", part1)
  3. part6.Size = Vector3.new(0.1,0.1,0.1)
  4. part6.Transparency = 1
  5. local weld = Instance.new("Weld", part6)
  6. weld.Part0 = part1
  7. weld.Part1 = partl6
  8. part6.CFrame = CFrame.new(0,0,1.5)
  9. local part4 = Instance.new("Part", game.Workspace)
  10. local part3 = Instance.new("Part", game.Workspace)
  11. local part5 = Instance.new("Part", game.Workspace)
  12. part1.Size = Vector3.new(1.487, 0.985, 2.72)
  13. part5.Size = Vector3.new(1.5, 1.5, 1.5)
  14. part1.Transparency = 1
  15. part5.Transparency = 1
  16. part4.Size = Vector3.new(1.487, 0.985, 2.72)
  17. Meshlol = Instance.new("SpecialMesh")
  18. Meshlol.Parent = part4
  19. Meshlol.MeshId = "http://www.roblox.com/asset/?id=2540334246"
  20. Meshlol.TextureId = "http://www.roblox.com/asset/?id=2540334261"
  21. Meshlol.Scale = Vector3.new(1, 1, 1)
  22. Meshlol2 = Instance.new("SpecialMesh")
  23. Meshlol2.Parent = part3
  24. Meshlol2.MeshId = "http://www.roblox.com/asset/?id=2540333861"
  25. Meshlol2.TextureId = "http://www.roblox.com/asset/?id=2540333887"
  26. Meshlol2.Scale = Vector3.new(1, 1, 1)
  27. part3.Size = Vector3.new(1.03, 1.044, 1.185)
  28. part3.CanCollide = false
  29. part1.Position = Vector3.new(10, 10, 10)
  30. part5.CanCollide = false
  31. part5.Anchored = true
  32. part5.Position = Vector3.new(10, 10, 10)
  33. Weld4 = Instance.new("Weld")
  34. Weld4.Parent = part1
  35. Weld4.Part0 = part1
  36. Weld4.Part1 = part4
  37. Weld4.part1 = part4
  38. Weld4.C1 = part4.CFrame * CFrame.Angles(0, math.rad(180), 0)
  39. local bg = Instance.new("BodyGyro",part1)
  40. bg.D = 100
  41. bg.P = 10000
  42. bg.MaxTorque = Vector3.new(400000, 400000, 400000)
  43. local bg2 = Instance.new("BodyGyro",part3)
  44. bg2.D = 100
  45. bg2.P = 10000
  46. bg2.MaxTorque = Vector3.new(0, 400000, 0)
  47. local bp = Instance.new("BodyPosition",part1)
  48. bp.D = 100
  49. bp.P = 10000
  50. bp.position = Vector3.new(10, 10, 10)
  51. local bp2 = Instance.new("BodyPosition",part3)
  52. bp2.D = 100
  53. bp2.P = 10000
  54. bp2.position = Vector3.new(10,9.25,10)
  55. part3.Position = Vector3.new(10,9.25,10)
  56. wait(0.1)
  57. part6.CanCollide = false
  58. part3.CFrame = part3.CFrame * CFrame.Angles(math.rad(180), 0, 0)
  59.  
  60. function move(target)
  61. local dir = (part5.Position - target.Position).unit
  62. local spawnPos = part5.Position
  63. local pos = spawnPos + (dir * 1)
  64. bg.cframe = CFrame.new(pos + dir, pos)
  65. bg2.cframe = CFrame.new(pos, pos + dir)
  66. end
  67.  
  68. function findNearestTorso(pos)
  69. local list = game.Workspace:GetChildren()
  70. local torso = nil
  71. local dist = 1000
  72. local temp = nil
  73. local human = nil
  74. local temp2 = nil
  75. for x = 1, #list do
  76. temp2 = list[x]
  77. if (temp2.className == "Model") and (temp2 ~= script.Parent) then
  78. temp = temp2:findFirstChild("Head")
  79. human = temp2:findFirstChild("Humanoid")
  80. if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
  81. if (temp.Position - pos).magnitude < dist then
  82. torso = temp
  83. dist = (temp.Position - pos).magnitude
  84. end
  85. end
  86. end
  87. end
  88. return torso
  89. end
  90. coroutine.wrap(function()
  91. while true do
  92. local torso = findNearestTorso(part5.Position)
  93. if torso~=nil then
  94. move(torso)
  95. end
  96. task.wait()
  97. end
  98. end)()
  99.  
  100. part12 = Instance.new("Part", game.Workspace)
  101. part12.Size = Vector3.new(10,10,0.05)
  102. part12.Anchored = true
  103. part12.Position = Vector3.new(20,5,0)
  104. part12.Reflectance = 1
  105. local screengui = Instance.new("SurfaceGui",owner.PlayerGui)
  106. screengui.Adornee = part12
  107. local viewportFrame = Instance.new("ViewportFrame",screengui)
  108. local viewportCamera = Instance.new("Camera",viewportFrame)
  109. test = Instance.new("RemoteEvent",owner.PlayerGui)
  110. game.Players.PlayerAdded:Connect(function(a)
  111. local screengui = screengui:Clone()
  112. screengui.Parent = a.PlayerGui
  113. screengui.Name = "hello"
  114. viewportFrame.Size = UDim2.new(1, 0, 1, 0)
  115. viewportFrame.Position = UDim2.new(0,0,0,0)
  116. viewportFrame.Name = "gaming"
  117. for i,v in pairs(game.Workspace:GetDescendants()) do
  118. if v:IsA("BasePart") then
  119. if not v:IsA("Terrain") then
  120. local part = v:Clone()
  121. part.Parent = viewportFrame
  122. screengui.Adornee = part12
  123. viewportFrame.CurrentCamera = viewportCamera
  124. end
  125. end
  126. end
  127. test.OnServerEvent:Connect(function(player,cf)
  128. local s, f = pcall(function()
  129. viewportCamera.CFrame = cf
  130. end)
  131. end)
  132. end)
  133. local s, f = pcall(function()
  134. for i, a in pairs(game.Players:GetChildren()) do
  135. if a:IsA("Player") then
  136. local screengui = screengui:Clone()
  137. screengui.Parent = a.PlayerGui
  138. screengui.Name = "hello"
  139. viewportFrame.Size = UDim2.new(1, 0, 1, 0)
  140. viewportFrame.Position = UDim2.new(0,0,0,0)
  141. viewportFrame.Name = "gaming"
  142. for i,v in pairs(game.Workspace:GetDescendants()) do
  143. if v:IsA("BasePart") then
  144. if not v:IsA("Terrain") then
  145. local part = v:Clone()
  146. part.Parent = viewportFrame
  147. screengui.Adornee = part12
  148. viewportFrame.CurrentCamera = viewportCamera
  149. end
  150. end
  151. end
  152. end
  153. test.OnServerEvent:Connect(function(player,cf)
  154. local s, f = pcall(function()
  155. viewportCamera.CFrame = cf
  156. end)
  157. end)
  158. end
  159. end)
  160. local s, f = pcall(function()
  161. for i,v in pairs(game.Workspace:GetDescendants()) do
  162. if v:IsA("BasePart") then
  163. if not v:IsA("Terrain") then
  164. local part = v:Clone()
  165. part.Parent = viewportFrame
  166. screengui.Face = Enum.NormalId.Front
  167. viewportFrame.BackgroundTransparency = 1
  168. end
  169. end
  170. end
  171. end)
  172. while true do
  173. for i,v in pairs(game.Workspace:GetDescendants()) do
  174. if v:IsA("BasePart") then
  175. if not v:IsA("Terrain") then
  176. cf = v.CFrame
  177. viewportCamera.CFrame = part1.CFrame
  178. task.wait()
  179. end
  180. end
  181. end
  182. end
Add Comment
Please, Sign In to add comment