Advertisement
ERROR_CODE

My nightmare 4

Apr 20th, 2024 (edited)
1,072
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.88 KB | None | 0 0
  1. if game.PlaceId ~= 337856574 then
  2. GameUI = Instance.new("ScreenGui")
  3. QuestionFrame = Instance.new("Frame")
  4. QuestionLabel = Instance.new("TextLabel")
  5. QuestionLabelUICorner = Instance.new("UICorner")
  6. QuestionFrameUICorner = Instance.new("UICorner")
  7. TextLabel = Instance.new("TextLabel")
  8. TextLabelUICorner = Instance.new("UICorner")
  9. YesButton = Instance.new("TextButton")
  10. YesButtonUICorner = Instance.new("UICorner")
  11. NoButton = Instance.new("TextButton")
  12. NoButtonUICorner = Instance.new("UICorner")
  13. Blur = Instance.new("BlurEffect")
  14. Blur.Parent = game:GetService("Lighting")
  15.  
  16. Blur.Size = 100
  17.  
  18. GameUI.Parent = game.CoreGui
  19.  
  20. QuestionFrame.Parent = GameUI
  21. QuestionFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  22. QuestionFrame.Position = UDim2.new(0.3, 0, 0.2, 0)
  23. QuestionFrame.Size = UDim2.new(0, 400, 0, 250)
  24.  
  25. QuestionLabel.Name = "QuestionLabel"
  26. QuestionLabel.Parent = QuestionFrame
  27. QuestionLabel.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  28. QuestionLabel.Size = UDim2.new(0, 400, 0, 25)
  29. QuestionLabel.Font = Enum.Font.Arcade
  30. QuestionLabel.Text = "Teleport"
  31. QuestionLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  32. QuestionLabel.TextSize = 30
  33.  
  34. QuestionFrameUICorner.Parent = QuestionFrame
  35.  
  36. QuestionLabelUICorner.Parent = QuestionLabel
  37.  
  38. TextLabel.Name = "TextLabel"
  39. TextLabel.Parent = QuestionFrame
  40. TextLabel.BackgroundTransparency = 1
  41. TextLabel.Position = UDim2.new(0.05, 0, 0.1, 0)
  42. TextLabel.Size = UDim2.new(0, 350, 0, 150)
  43. TextLabel.Font = Enum.Font.Arcade
  44. TextLabel.Text = "To play in 'My nightmare 4' you need to bee in special game. If you press on 'Yes' button you will teleport in this game, after that you need to re-execue script."
  45. TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  46. TextLabel.TextSize = 30
  47. TextLabel.TextWrapped = true
  48. TextLabel.TextScaled = true
  49.  
  50. TextLabelUICorner.Parent = TextLabel
  51.  
  52. NoButton.Name = "NoButton"
  53. NoButton.Parent = QuestionFrame
  54. NoButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  55. NoButton.Position = UDim2.new(0.07, 0, 0.7, 0)
  56. NoButton.Size = UDim2.new(0, 125, 0, 50)
  57. NoButton.Font = Enum.Font.Arcade
  58. NoButton.Text = "No"
  59. NoButton.TextColor3 = Color3.fromRGB(0, 0, 0)
  60. NoButton.TextScaled = true
  61. NoButton.TextSize = 14.000
  62. NoButton.TextWrapped = true
  63. NoButton.MouseButton1Down:connect(function()
  64. GameUI:Destroy()
  65. Blur.Size = 0
  66. end)
  67. NoButtonUICorner.Parent = NoButton
  68.  
  69. YesButton.Name = "YesButton"
  70. YesButton.Parent = QuestionFrame
  71. YesButton.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
  72. YesButton.Position = UDim2.new(0.6, 0, 0.7, 0)
  73. YesButton.Size = UDim2.new(0, 125, 0, 50)
  74. YesButton.Font = Enum.Font.Arcade
  75. YesButton.Text = "Yes"
  76. YesButton.TextColor3 = Color3.fromRGB(0, 0, 0)
  77. YesButton.TextScaled = true
  78. YesButton.TextSize = 14.000
  79. YesButton.TextWrapped = true
  80. YesButton.MouseButton1Down:connect(function()
  81. TeleportService = game:GetService("TeleportService")
  82. PId = 337856574
  83. JobId = game.JobId
  84. if #game.Players:GetPlayers() <= 1 then
  85.         game.Players.LocalPlayer:Kick("Teleporting...")
  86.         wait()
  87.         TeleportService:Teleport(PId, game.Players.LocalPlayer)
  88.     else
  89.         TeleportService:TeleportToPlaceInstance(PId, JobId, game.Players.LocalPlayer)
  90.     end
  91. end)
  92. YesButtonUICorner.Parent = YesButton
  93. else
  94. if loaded then
  95. game.Players.LocalPlayer:Kick("Restart")
  96. TeleportService = game:GetService("TeleportService")
  97. Players = game:GetService("Players")
  98. LocalPlayer = Players.LocalPlayer
  99.  
  100. local Rejoin = coroutine.create(function()
  101.     local Success, ErrorMessage = pcall(function()
  102.         TeleportService:Teleport(game.PlaceId, LocalPlayer)
  103.     end)
  104.  
  105.     if ErrorMessage and not Success then
  106.         warn(ErrorMessage)
  107.     end
  108. end)
  109.  
  110. coroutine.resume(Rejoin)
  111. end
  112. pcall(function()
  113.     getgenv().loaded = true
  114. game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
  115. game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.Classic
  116. game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
  117. GameUI = Instance.new("ScreenGui")
  118. Static = Instance.new("ImageLabel")
  119. GameName = Instance.new("TextLabel")
  120. Part1 = Instance.new("Part")
  121. Cam = workspace.CurrentCamera
  122. Character = game.Players.LocalPlayer.Character
  123. Play = Instance.new("TextButton")
  124. Quit = Instance.new("TextButton")
  125. MenuSound = Instance.new("Sound")
  126. MainSound = Instance.new("Sound")
  127. StopGameButton = Instance.new("TextButton")
  128. HoverSound = Instance.new("Sound")
  129. Part2 = Instance.new("Part")
  130.  
  131. GameUI.Parent = game.CoreGui
  132.  
  133. Part1.Parent = workspace
  134. Part1.Anchored = true
  135. Part1.Size = Vector3.new(4, 1, 2)
  136. Part1.CanCollide = false
  137. Part1.Rotation = Vector3.new(0, 0, 0)
  138. Part1.Position = Vector3.new(128.94, 20.96, -333.17)
  139. Part1.Transparency = 1
  140.  
  141. Part2.Parent = workspace
  142. Part2.Anchored = true
  143. Part2.Size = Vector3.new(4, 1, 2)
  144. Part2.CanCollide = false
  145. Part2.Rotation = Vector3.new(-19.91, -73.08, -1.23)
  146. Part2.Position = Vector3.new(-2.81, 2.86, 58.71)
  147. Part2.Transparency = 1
  148.  
  149. MenuSound.Parent = game.Workspace
  150. MenuSound.SoundId = "rbxassetid://1844779909"
  151. MenuSound.Playing = true
  152. MenuSound.Looped = true
  153. MenuSound.Volume = 1
  154.  
  155. MainSound.Parent = game.Workspace
  156. MainSound.SoundId = "rbxassetid://1837115475"
  157. MainSound.Playing = true
  158. MainSound.Looped = true
  159. MainSound.Volume = 1
  160. MainSound:Stop()
  161.  
  162. HoverSound.Parent = game.Workspace
  163. HoverSound.SoundId = "rbxassetid://9120133107"
  164. HoverSound.Playing = true
  165. HoverSound.Looped = false
  166. HoverSound.Volume = 1
  167. HoverSound:Stop()
  168.  
  169. Cam.CameraSubject = Part2
  170. Cam.CameraType = Enum.CameraType.Attach
  171.  
  172. GameName.Parent = GameUI
  173. GameName.BackgroundTransparency = 1
  174. GameName.Size = UDim2.new(2, 0, 2, 0)
  175. GameName.Position = UDim2.new(-0.5, 0, -0.6 ,0)
  176. GameName.TextXAlignment = Enum.TextXAlignment.Center
  177. GameName.TextScaled = true
  178. GameName.Text = "My nightmare 4"
  179. GameName.TextColor3 = Color3.new(255, 255, 255)
  180. GameName.Font = Enum.Font.Arcade
  181.  
  182. Play.Name = "Play"
  183. Play.Parent = GameUI
  184. Play.Position = UDim2.new(0.2, 0, 0.6 ,0)
  185. Play.Size = UDim2.new(0, 150, 0, 80)
  186. Play.Font = Enum.Font.Arcade
  187. Play.Text = "Play"
  188. Play.TextColor3 = Color3.fromRGB(255, 255, 255)
  189. Play.TextSize = 60
  190. Play.BackgroundColor3 = Color3.fromRGB(94, 54, 226)
  191. Play.BorderColor3 = Color3.fromRGB(0, 0, 0)
  192. Play.BorderSizePixel = 5
  193. Play.AutoButtonColor = false
  194.  
  195. Quit.Name = "Quit"
  196. Quit.Parent = GameUI
  197. Quit.Position = UDim2.new(0.6, 0, 0.6 ,0)
  198. Quit.Size = UDim2.new(0, 150, 0, 80)
  199. Quit.Font = Enum.Font.Arcade
  200. Quit.Text = "Quit"
  201. Quit.TextColor3 = Color3.fromRGB(255, 255, 255)
  202. Quit.TextSize = 60
  203. Quit.BackgroundColor3 = Color3.fromRGB(94, 54, 226)
  204. Quit.BorderColor3 = Color3.fromRGB(0, 0, 0)
  205. Quit.BorderSizePixel = 5
  206. Quit.AutoButtonColor = false
  207.  
  208. StopGameButton.Name = "StopGameButton"
  209. StopGameButton.Parent = GameUI
  210. StopGameButton.Position = UDim2.new(0.85, 0, 0.05 ,0)
  211. StopGameButton.Size = UDim2.new(0, 100, 0, 30)
  212. StopGameButton.Font = Enum.Font.Arcade
  213. StopGameButton.Text = "Stop"
  214. StopGameButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  215. StopGameButton.TextSize = 50
  216. StopGameButton.BackgroundColor3 = Color3.fromRGB(226, 54, 94)
  217. StopGameButton.BorderColor3 = Color3.fromRGB(0, 0, 0)
  218. StopGameButton.BorderSizePixel = 5
  219. StopGameButton.Visible = false
  220. StopGameButton.AutoButtonColor = false
  221.  
  222. Static.Parent = GameUI
  223. Static.Size = UDim2.new(1,0,1,100)
  224. Static.Position = UDim2.new(0,0,0,-100)
  225. Static.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  226. Static.Image = "rbxassetid://13928716599"
  227. Static.Visible = false
  228.  
  229. spawn(function()
  230. while wait(1) do
  231. StaticTime = math.random(1,3)
  232. if StaticTime == 1 then
  233. wait(1)
  234. Static.Visible = true
  235. wait()
  236. Static.Visible = false
  237. end
  238. if StaticTime == 2 then
  239. wait(5)
  240. Static.Visible = true
  241. wait()
  242. Static.Visible = false
  243. end
  244. if StaticTime == 3 then
  245. wait()
  246. Static.Visible = true
  247. wait()
  248. Static.Visible = false
  249. end
  250. end
  251. end)
  252. Play.MouseButton1Click:connect(function()
  253. Cam.CameraSubject = Part1
  254. Cam.CameraType = Enum.CameraType.Track
  255. GameName.Visible = false
  256. Play.Visible = false
  257. Quit.Visible = false
  258. MenuSound:Stop()
  259. MainSound:Play()
  260. StopGameButton.Visible = true
  261. game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(132, 20.96, -333.17)
  262. end)
  263.  
  264. Quit.MouseButton1Click:connect(function()
  265. game.Players.LocalPlayer:Kick("Bye")
  266. end)
  267.  
  268. StopGameButton.MouseButton1Click:connect(function()
  269. Cam.CameraSubject = Part1
  270. Cam.CameraType = Enum.CameraType.Attach
  271. GameName.Visible = true
  272. Play.Visible = true
  273. Quit.Visible = true
  274. MenuSound:Play()
  275. MainSound:Stop()
  276. StopGameButton.Visible = false
  277. end)
  278.  
  279.  
  280. Play.MouseEnter:Connect(function()
  281. Play.Size = UDim2.new(0, 160, 0, 90)
  282. HoverSound:Play()
  283. end)
  284.    
  285. Play.MouseLeave:Connect(function()
  286. Play.Size = UDim2.new(0, 150, 0, 80)  
  287. end)
  288.  
  289. Quit.MouseEnter:Connect(function()
  290. Quit.Size = UDim2.new(0, 160, 0, 90)
  291. HoverSound:Play()
  292. end)
  293.    
  294. Quit.MouseLeave:Connect(function()
  295. Quit.Size = UDim2.new(0, 150, 0, 80)  
  296. end)
  297.  
  298. StopGameButton.MouseEnter:Connect(function()
  299. StopGameButton.Size = UDim2.new(0, 110, 0, 40)
  300. HoverSound:Play()
  301. end)
  302.    
  303. StopGameButton.MouseLeave:Connect(function()
  304. StopGameButton.Size = UDim2.new(0, 100, 0, 30)  
  305. end)
  306.  
  307.  
  308.  
  309. local Camera = workspace.CurrentCamera
  310. local Player = game.Players.LocalPlayer
  311.  
  312. local Character = Player.Character
  313. local Root = Character:WaitForChild("HumanoidRootPart")
  314. local Neck = Character:FindFirstChild("Neck", true)
  315. local YOffset = Neck.C0.Y
  316.  
  317. local CFNew, CFAng = CFrame.new, CFrame.Angles
  318. local asin = math.asin
  319.  
  320. game:GetService("RunService").RenderStepped:Connect(function()
  321.     local CameraDirection = Root.CFrame:toObjectSpace(Camera.CFrame).lookVector
  322.     if Neck then
  323.         if Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
  324.             Neck.C0 = CFNew(0, YOffset, 0) * CFAng(0, -asin(CameraDirection.x), 0) * CFAng(asin(CameraDirection.y), 0, 0)
  325.         elseif Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
  326.             Neck.C0 = CFNew(0, YOffset, 0) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(0, 0, -asin(CameraDirection.x)) * CFAng(-asin(CameraDirection.y), 0, 0)
  327.         end
  328.     end
  329. end)
  330.  
  331. end)
  332. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement