TheUnknownDiscord

2d engine

Mar 5th, 2022 (edited)
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.71 KB | None | 0 0
  1. part1 = Instance.new("Part", owner.Character)
  2. part1.Size = Vector3.new(5,5,0.1)
  3. part1.Anchored = true
  4. part1.CFrame = owner.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,2)
  5. local screengui2 = Instance.new("SurfaceGui", part1)
  6. screengui2.Name = "Hud"
  7. screengui2.Face = Enum.NormalId.Back
  8. local fake3 = Instance.new("Frame", screengui2)
  9. fake3.BackgroundTransparency = 1
  10. fake3.Size = UDim2.new(0.75,0,0.75,0)
  11. fake3.AnchorPoint = Vector2.new(0.5, 0.5)
  12. fake3.Position = UDim2.new(0.5, 0, 0.5, 0)
  13. fake3.ClipsDescendants = true
  14. local fake = Instance.new("Frame", fake3)
  15. fake.BackgroundTransparency = 0
  16. fake.Size = UDim2.new(0.45,0,0.125,0)
  17. fake.AnchorPoint = Vector2.new(0.5, 0.85)
  18. fake.Position = UDim2.new(0.5, 0, 0.85, 0)
  19. local fake4 = Instance.new("Frame", fake3)
  20. fake4.BackgroundTransparency = 0
  21. fake4.Size = UDim2.new(1,0,0.125,0)
  22. fake4.AnchorPoint = Vector2.new(0.5, 1)
  23. fake4.Position = UDim2.new(0.5, 0, 1, 0)
  24. fake4.BackgroundColor3 = Color3.fromRGB(255, 17, 0)
  25. local grad = Instance.new("UIGradient",fake4)
  26. grad.Color = ColorSequence.new(Color3.fromRGB(255, 17, 0), Color3.fromRGB(255, 128, 0))
  27. local fake2 = Instance.new("Frame", fake3)
  28. fake2.BackgroundTransparency = 0
  29. fake2.Size = UDim2.new(0.45,0,0.125,0)
  30. fake2.AnchorPoint = Vector2.new(1.5, 0.85)
  31. fake2.Position = UDim2.new(1.5, 0, 0.85, 0)
  32. local fake5 = Instance.new("Frame", fake3)
  33. fake5.BackgroundTransparency = 0
  34. fake5.Size = UDim2.new(0.15,0,0.5,0)
  35. fake5.AnchorPoint = Vector2.new(1.75, 0.4)
  36. fake5.Position = UDim2.new(1.75, 0, 0.4, 0)
  37. local fake6 = Instance.new("Frame", fake3)
  38. fake6.BackgroundTransparency = 0
  39. fake6.Size = UDim2.new(0.15,0,0.15,0)
  40. fake6.AnchorPoint = Vector2.new(1.7, 0.3)
  41. fake6.Position = UDim2.new(1.7, 0, 0.3, 0)
  42. fake6.BackgroundColor3 = Color3.fromRGB(52, 235, 61)
  43. prox = Instance.new("ProximityPrompt",owner.Character.Head)
  44. prox.Style = Enum.ProximityPromptStyle.Custom
  45. prox.Enabled = true
  46. prox.KeyboardKeyCode = Enum.KeyCode.D
  47. prox3 = Instance.new("ProximityPrompt",owner.Character.Head)
  48. prox3.Style = Enum.ProximityPromptStyle.Custom
  49. prox3.Enabled = true
  50. prox3.KeyboardKeyCode = Enum.KeyCode.Space
  51. local right = false
  52. local jump = false
  53. prox.Triggered:Connect(function(player)
  54. if player == owner then
  55. right = true
  56. end
  57. end)
  58. prox.TriggerEnded:Connect(function(player)
  59. if player == owner then
  60. right = false
  61. end
  62. end)
  63. prox2 = Instance.new("ProximityPrompt",owner.Character.Head)
  64. prox2.Style = Enum.ProximityPromptStyle.Custom
  65. prox2.Enabled = true
  66. prox2.KeyboardKeyCode = Enum.KeyCode.A
  67. local left = false
  68. prox2.Triggered:Connect(function(player)
  69. if player == owner then
  70. left = true
  71. end
  72. end)
  73. prox3.Triggered:Connect(function(player)
  74. if player == owner then
  75. jump = true
  76. wait(0.125)
  77. jump = false
  78. end
  79. end)
  80. prox2.TriggerEnded:Connect(function(player)
  81. if player == owner then
  82. left = false
  83. end
  84. end)
  85. local A = Instance.new("Sound", part1)
  86. A.SoundId = "rbxassetid://5652761093"
  87. A.Volume = 2
  88. local frame = Instance.new("ImageLabel", screengui2)
  89. frame.BackgroundTransparency = 1
  90. frame.Image = "http://www.roblox.com/asset/?id=9015080727"
  91. frame.Size = UDim2.new(0.125,0,0.125,0)
  92. frame.AnchorPoint = Vector2.new(0.5, 0.5)
  93. frame.Position = UDim2.new(0.5, 0, 0.5, 0)
  94. frame.Image = "rbxassetid://9014464566"
  95. frame.ImageRectSize = Vector2.new(540, 540)
  96. local tl = Instance.new("TextBox", screengui2)
  97. tl.Size = UDim2.new(0.5, 0, 0.125, 0)
  98. tl.BackgroundTransparency = 1
  99. tl.AnchorPoint = Vector2.new(0.5, 0.35)
  100. tl.Position = UDim2.new(0.5, 0, 0.35, 0)
  101. tl.Text = ""
  102. tl.TextSize = 25
  103. local frame2 = Instance.new("Frame", frame)
  104. frame2.BackgroundTransparency = 1
  105. frame2.Size = UDim2.new(0.75,0,1,0)
  106. frame2.AnchorPoint = Vector2.new(0.5, 0.5)
  107. frame2.Position = UDim2.new(0.5, 0, 0.5, 0)
  108. local frames = {
  109. Vector2.new(0, 0); Vector2.new(1, 0);
  110. }
  111. coroutine.wrap(function()
  112. while true do
  113. for i = 1, #frames do
  114. frame.ImageRectOffset = frames[i] * frame.ImageRectSize
  115. wait(.2)
  116. end
  117. end
  118. end)()
  119. local db = false
  120. function imdead()
  121. if db then return end
  122. db = true
  123. A:Play()
  124. tl.Text = "you are the kil"
  125. end
  126. function thewin()
  127. if db then return end
  128. db = true
  129. tl.Text = "you are done the win!111!"
  130. end
  131. function collidesWith(gui1, gui2,gui3,gui4,gui5,gui6)
  132. local gui1_topLeft = gui1.AbsolutePosition
  133. local gui1_bottomRight = gui1_topLeft + gui1.AbsoluteSize
  134. local gui3_topLeft = gui3.AbsolutePosition
  135. local gui3_bottomRight = gui3_topLeft + gui3.AbsoluteSize
  136. local gui4_topLeft = gui4.AbsolutePosition
  137. local gui4_bottomRight = gui4_topLeft + gui4.AbsoluteSize
  138. local gui5_topLeft = gui5.AbsolutePosition
  139. local gui5_bottomRight = gui5_topLeft + gui5.AbsoluteSize
  140. local gui6_topLeft = gui6.AbsolutePosition
  141. local gui6_bottomRight = gui6_topLeft + gui6.AbsoluteSize
  142. local gui2_topLeft = gui2.AbsolutePosition
  143. local gui2_bottomRight = gui2_topLeft + gui2.AbsoluteSize
  144.  
  145. return ((gui1_topLeft.x < gui2_bottomRight.x and gui1_bottomRight.x > gui2_topLeft.x) and (gui1_topLeft.y < gui2_bottomRight.y and gui1_bottomRight.y > gui2_topLeft.y)), ((gui3_topLeft.x < gui2_bottomRight.x and gui3_bottomRight.x > gui2_topLeft.x) and (gui3_topLeft.y < gui2_bottomRight.y and gui3_bottomRight.y > gui2_topLeft.y)), ((gui4_topLeft.x < gui2_bottomRight.x and gui4_bottomRight.x > gui2_topLeft.x) and (gui4_topLeft.y < gui2_bottomRight.y and gui4_bottomRight.y > gui2_topLeft.y)), ((gui5_topLeft.x < gui2_bottomRight.x and gui5_bottomRight.x > gui2_topLeft.x) and (gui5_topLeft.y < gui2_bottomRight.y and gui5_bottomRight.y > gui2_topLeft.y)),((gui6_topLeft.x < gui2_bottomRight.x and gui6_bottomRight.x > gui2_topLeft.x) and (gui6_topLeft.y < gui2_bottomRight.y and gui6_bottomRight.y > gui2_topLeft.y))
  146. end
  147. dead = false
  148. canjump = true
  149. while true do
  150. task.wait()
  151. local grav,grav2,death,wall,won = collidesWith(fake,frame2,fake2,fake4,fake5,fake6)
  152. if death then
  153. imdead()
  154. dead = true
  155. end
  156. if won then
  157. thewin()
  158. dead = true
  159. end
  160. if grav == false and grav2 == false and not dead then
  161. fake.Position = fake.Position + UDim2.new(0, 0, -0.00325, 0)
  162. fake2.Position = fake2.Position + UDim2.new(0, 0, -0.00325, 0)
  163. fake4.Position = fake4.Position + UDim2.new(0, 0, -0.00325, 0)
  164. fake5.Position = fake5.Position + UDim2.new(0, 0, -0.00325, 0)
  165. fake6.Position = fake6.Position + UDim2.new(0, 0, -0.00325, 0)
  166. elseif not dead then
  167. canjump = true
  168. end
  169. if wall then
  170. fake.Position = fake.Position + UDim2.new(0.0125, 0, 0, 0)
  171. fake2.Position = fake2.Position + UDim2.new(0.0125, 0, 0, 0)
  172. fake5.Position = fake5.Position + UDim2.new(0.0125, 0, 0, 0)
  173. fake6.Position = fake6.Position + UDim2.new(0.0125, 0, 0, 0)
  174. end
  175. if jump and not dead and canjump then
  176. canjump = false
  177. fake.Position = fake.Position + UDim2.new(0, 0, 0.25, 0)
  178. fake2.Position = fake2.Position + UDim2.new(0, 0, 0.25, 0)
  179. fake4.Position = fake4.Position + UDim2.new(0, 0, 0.25, 0)
  180. fake5.Position = fake5.Position + UDim2.new(0, 0, 0.25, 0)
  181. fake6.Position = fake6.Position + UDim2.new(0, 0, 0.25, 0)
  182. end
  183. if left and not dead then
  184. fake.Position = fake.Position + UDim2.new(0.0125, 0, 0, 0)
  185. fake2.Position = fake2.Position + UDim2.new(0.0125, 0, 0, 0)
  186. fake5.Position = fake5.Position + UDim2.new(0.0125, 0, 0, 0)
  187. fake6.Position = fake6.Position + UDim2.new(0.0125, 0, 0, 0)
  188. frame.Image = "http://www.roblox.com/asset/?id=9015078080"
  189. elseif right and not dead then
  190. fake.Position = fake.Position + UDim2.new(-0.0125, 0, 0, 0)
  191. fake2.Position = fake2.Position + UDim2.new(-0.0125, 0, 0, 0)
  192. fake5.Position = fake5.Position + UDim2.new(-0.0125, 0, 0, 0)
  193. fake6.Position = fake6.Position + UDim2.new(-0.0125, 0, 0, 0)
  194. frame.Image = "http://www.roblox.com/asset/?id=9015080727"
  195. end
  196. end
Add Comment
Please, Sign In to add comment