Advertisement
Sungmingamerpro13

Hide System(Local Script)

Feb 14th, 2023
1,231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.90 KB | None | 0 0
  1. -- LOCAL SCRIPT --
  2.  
  3. local tweenService = game:GetService("TweenService")
  4. local userInputService = game:GetService("UserInputService")
  5. local replicatedStorage = game:GetService("ReplicatedStorage")
  6.  
  7. local event = replicatedStorage:WaitForChild("HideEvent")
  8.  
  9. local player = game.Players.LocalPlayer
  10. local character = player.Character or player.CharacterAdded:Wait()
  11.  
  12. local effect = script.Parent.Effect
  13. local camera = workspace.CurrentCamera
  14.  
  15. local keyConnection = nil
  16. local keys = {Enum.KeyCode.W, Enum.KeyCode.A, Enum.KeyCode.D, Enum.KeyCode.S}
  17.  
  18. event.OnClientEvent:Connect(function(model)
  19.     camera.CameraType = Enum.CameraType.Scriptable
  20.     camera.CameraSubject = model.InsideCamera
  21.    
  22.     for i, v in pairs(character:GetDescendants()) do
  23.         if v:IsA("BasePart") or v:IsA("Decal") then
  24.             v.Transparency = 1
  25.         end
  26.     end
  27.    
  28.     local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
  29.     tweenService:Create(camera, tweenInfo, {CFrame = model.InsideCamera.CFrame}):Play()
  30.    
  31.     for i = 1, 0, -0.01 do
  32.         effect.BackgroundTransparency = i
  33.         task.wait()
  34.     end
  35.    
  36.     task.wait(0.7)
  37.    
  38.     keyConnection = userInputService.InputBegan:Connect(function(input)
  39.         if table.find(keys, input.KeyCode) then
  40.             keyConnection:Disconnect()
  41.             event:FireServer(model)
  42.            
  43.             local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
  44.             tweenService:Create(camera, tweenInfo, {CFrame = model.OutsideCamera.CFrame}):Play()
  45.            
  46.             task.spawn(function()
  47.                 for i = 0, 1, 0.01 do
  48.                     effect.BackgroundTransparency = i
  49.                     task.wait()
  50.                 end
  51.             end)
  52.            
  53.             task.wait(tweenInfo.Time)
  54.            
  55.             camera.CameraType = Enum.CameraType.Custom
  56.             camera.CameraSubject = character           
  57.            
  58.             for i, v in pairs(character:GetDescendants()) do
  59.                 if v.Name ~= "HumanoidRootPart" and (v:IsA("BasePart") or v:IsA("Decal")) then
  60.                     v.Transparency = 0
  61.                 end
  62.             end
  63.         end
  64.     end)
  65. end)
  66.  
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement