Advertisement
Scripting_King

Untitled

Aug 8th, 2023
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.30 KB | Source Code | 0 0
  1. local SoundService = game:GetService("SoundService")
  2. local musicToDecrease = game.Workspace.ParadiseFalls
  3. local soundLoadedEvent = Instance.new("BindableEvent")
  4. local sound = game.StarterPlayer.StarterPlayerScripts.DoorOpening.Horror
  5. local StoneDoorSoundId = "rbxassetid://1843660604"
  6. local Hinge = workspace.Door1.PrimaryPart
  7. local Door = workspace.Door1
  8. local TweenSetvice = game:GetService("TweenService")
  9. local musicTweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0)
  10. local MusicVolumeGoal = {
  11.     Volume = 0
  12. }
  13. local MusicVolumeIncreaseGoal = {
  14.     Volume = 0.3
  15. }
  16. local decreaseMusicTween = TweenSetvice:Create(musicToDecrease, musicTweenInfo, MusicVolumeGoal)
  17. local IncreaseMusicTween = TweenSetvice:Create(musicToDecrease, musicTweenInfo, MusicVolumeIncreaseGoal)
  18. local primary = game.Workspace.DoorsFigureKiller.PrimaryPart
  19. local Ghost = game.Workspace.DoorsFigureKiller
  20. local light = game.Workspace.GhostLight
  21. local Debounce = false
  22. local startTimeToSkip = 5
  23. local ShakeEvent = game.ReplicatedStorage:WaitForChild("ShakeEvent")
  24. local ShowHorrorImage = game.ReplicatedStorage:WaitForChild("ShowImage")
  25.  
  26. local opened = false
  27.  
  28. local Promt = workspace.Door1:WaitForChild("ProximityPrompt")
  29.  
  30.  
  31. -- this will open the door if it is close and close if it is already opened
  32. function OpenDoor()
  33.     if opened == false then
  34.         opened = true
  35.         for i = 1, 18 do
  36.             Door:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(5), 0))
  37.             wait()
  38.         end
  39.     else
  40.         opened = false
  41.         for i = 1, 18 do
  42.             Door:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(-5), 0))
  43.             wait()
  44.         end
  45.     end
  46. end
  47.  
  48. -- Moving Ghost
  49. local LightTweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false)
  50.  
  51. local LightTarget = {
  52.     CFrame = light.CFrame + Vector3.new(light.Size.X + 30, 0, 0)
  53. }
  54.  
  55. local GhostTweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false)
  56. local target = {
  57.     CFrame = primary.CFrame + Vector3.new(primary.Size.X + 30, 0, 0)
  58. }
  59.  
  60. local GhostTween = TweenSetvice:Create(primary, GhostTweenInfo, target)
  61. local LightTween = TweenSetvice:Create(light, LightTweenInfo, LightTarget)
  62.  
  63.  
  64.  
  65.  -- This function will run first time when player open the door and than player see ghost moving toward wall and they ghost destroy
  66. Promt.Triggered:Connect(function(player)
  67.     if not Debounce then
  68.         Debounce = true
  69.         OpenDoor()
  70.         task.wait(1)
  71.         GhostTween:Play()
  72.         LightTween:Play()
  73.         local character = player.Character or player.CharacterAdded:Wait()
  74.         local Humanoid = character:WaitForChild("Humanoid")
  75.         local torso = character:FindFirstChild("Torso") or character:FindFirstChild("UpperTorso")
  76.         local playerGui = player:WaitForChild("PlayerGui")
  77.         local gui = playerGui:WaitForChild("ScreenGui")
  78.  
  79.         if torso then
  80.             while wait() do
  81.                 if Humanoid.Health == 0 then
  82.                     OpenDoor()
  83.                     return
  84.                 end        
  85.                 local distance = (Door.Hinge.Position - torso.Position).magnitude
  86.                 if distance > 25 then
  87.                     ShakeEvent.OnClientEvent:Connect(function(Time)
  88.                        
  89.                         sound.TimePosition = startTimeToSkip
  90.                         sound:Play()
  91.                         decreaseMusicTween:Play()
  92.  
  93.  
  94.  
  95.                         local StartTime = tick()
  96.  
  97.  
  98.  
  99.                         repeat
  100.  
  101.                             wait()
  102.  
  103.                             local EndTime = tick()
  104.  
  105.                             local xOffset = math.random(-100, 100) / 500
  106.                             local yOffset = math.random(-100, 100) / 500
  107.                             local zOffset = math.random(-100, 100) / 500
  108.  
  109.                             Humanoid.CameraOffset = Vector3.new(xOffset, yOffset, zOffset)
  110.  
  111.                         until EndTime - StartTime >= Time
  112.                         Humanoid.CameraOffset = Vector3.new(0, 0, 0)
  113.                     end)
  114.  
  115.                     wait(2)
  116.  
  117.                     gui.Enabled = true
  118.  
  119.                     local blur = Instance.new("BlurEffect")
  120.                     blur.Parent = game.Lighting -- [IMPORTANT:] Do NOT change the parent otherwise it won't work.
  121.                     blur.Size = 6
  122.                     wait(2) -- How long the shake effect is for
  123.                     blur.Size = 5
  124.                     wait(0.1) -- You change this if you want
  125.                     blur.Size = 4
  126.                     wait(0.1) -- You change this if you want
  127.                     blur.Size = 3
  128.                     wait(0.1) -- You change this if you want
  129.                     blur.Size = 2
  130.                     wait(0.1) -- You change this if you want
  131.                     blur.Size = 1
  132.                     wait(0.1) -- You change this if you want
  133.                     blur.Size = 0
  134.  
  135.                     blur:Destroy()
  136.                     if Humanoid.Health ~= 0 then
  137.                         Humanoid:TakeDamage(Humanoid.MaxHealth)
  138.                     end
  139.                     gui.Enabled = false
  140.                     sound:Pause()
  141.                     OpenDoor()
  142.                     wait(1)
  143.                     IncreaseMusicTween:Play()
  144.                     return
  145.  
  146.                 end
  147.             end
  148.         end
  149.        
  150.     end
  151.  
  152. end)
  153.  
  154. LightTween.Completed:Connect(function()
  155.     light:Destroy()
  156. end)
  157. GhostTween.Completed:Connect(function()
  158.     Ghost:Destroy()
  159. end)
  160.  
  161.  
  162.  
  163.  
  164.  -- This function will run when player open the door second time so player will not able to see ghost again and again
  165. Promt.Triggered:Connect(function(player)
  166.     if Debounce then
  167.         OpenDoor()
  168.         local character = player.Character or player.CharacterAdded:Wait()
  169.         local Humanoid = character:WaitForChild("Humanoid")
  170.         local torso = character:FindFirstChild("Torso") or character:FindFirstChild("UpperTorso")
  171.         local playerGui = player:WaitForChild("PlayerGui")
  172.         local gui = playerGui:WaitForChild("ScreenGui")
  173.        
  174.         if torso then
  175.             while wait() do
  176.                 if Humanoid.Health == 0 then
  177.                     OpenDoor()
  178.                 end
  179.                 local distance = (Door.Hinge.Position - torso.Position).magnitude
  180.                 if distance > 25 then
  181.                     ShakeEvent.OnClientEvent:Connect(function(Time)
  182.  
  183.                         local StartTime = tick()
  184.  
  185.  
  186.  
  187.                         repeat
  188.  
  189.                             wait()
  190.  
  191.                             local EndTime = tick()
  192.  
  193.                             local xOffset = math.random(-100, 100) / 500
  194.                             local yOffset = math.random(-100, 100) / 500
  195.                             local zOffset = math.random(-100, 100) / 500
  196.  
  197.                             Humanoid.CameraOffset = Vector3.new(xOffset, yOffset, zOffset)
  198.  
  199.                         until EndTime - StartTime >= Time
  200.                         Humanoid.CameraOffset = Vector3.new(0, 0, 0)
  201.                     end)
  202.  
  203.                     wait(2)
  204.    
  205.                         gui.Enabled = true
  206.                    
  207.                     local blur = Instance.new("BlurEffect")
  208.                     blur.Parent = game.Lighting -- [IMPORTANT:] Do NOT change the parent otherwise it won't work.
  209.                     blur.Size = 6
  210.                     wait(2) -- How long the shake effect is for
  211.                     blur.Size = 5
  212.                     wait(0.1) -- You change this if you want
  213.                     blur.Size = 4
  214.                     wait(0.1) -- You change this if you want
  215.                     blur.Size = 3
  216.                     wait(0.1) -- You change this if you want
  217.                     blur.Size = 2
  218.                     wait(0.1) -- You change this if you want
  219.                     blur.Size = 1
  220.                     wait(0.1) -- You change this if you want
  221.                     blur.Size = 0
  222.  
  223.                     blur:Destroy()
  224.                     Humanoid:TakeDamage(Humanoid.MaxHealth)
  225.                     gui.Enabled = false
  226.                     OpenDoor()
  227.                     return
  228.                    
  229.                 end
  230.             end
  231.         end
  232.     end
  233. end)
  234.  
  235.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement