Advertisement
Sungmingamerpro13

Hide System(Server Script-Rainbow Friends)

Feb 4th, 2023 (edited)
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 2.95 KB | None | 0 0
  1. -- SERVER SCRIPT --
  2.  
  3. local tweenSerice = game:GetService("TweenService")
  4. local replicatedStorage = game:GetService("ReplicatedStorage")
  5.  
  6. local event = replicatedStorage:WaitForChild("HideEvent")
  7. local closets = script.Parent:GetChildren()
  8.  
  9. local function Animation(model, action)
  10.     local hinge1 = model:WaitForChild("Hinge1")
  11.     local hinge2 = model:WaitForChild("Hinge2")
  12.    
  13.     if action == "Exit" then
  14.         local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
  15.         tweenSerice:Create(hinge1, tweenInfo, {CFrame = hinge1.CFrame * CFrame.Angles(0, math.rad(80), 0)}):Play()
  16.         tweenSerice:Create(hinge2, tweenInfo, {CFrame = hinge2.CFrame * CFrame.Angles(0, math.rad(-80), 0)}):Play()
  17.  
  18.         task.wait(tweenInfo.Time)
  19.        
  20.         local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
  21.         tweenSerice:Create(hinge1, tweenInfo, {CFrame = hinge1.CFrame * CFrame.Angles(0, math.rad(-100), 0)}):Play()
  22.         tweenSerice:Create(hinge2, tweenInfo, {CFrame = hinge2.CFrame * CFrame.Angles(0, math.rad(100), 0)}):Play()
  23.     elseif action == "Enter" then
  24.         local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
  25.         tweenSerice:Create(hinge1, tweenInfo, {CFrame = hinge1.CFrame * CFrame.Angles(0, math.rad(100), 0)}):Play()
  26.         tweenSerice:Create(hinge2, tweenInfo, {CFrame = hinge2.CFrame * CFrame.Angles(0, math.rad(-100), 0)}):Play()
  27.  
  28.         task.wait(tweenInfo.Time)
  29.  
  30.         local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
  31.         tweenSerice:Create(hinge1, tweenInfo, {CFrame = hinge1.CFrame * CFrame.Angles(0, math.rad(-80), 0)}):Play()
  32.         tweenSerice:Create(hinge2, tweenInfo, {CFrame = hinge2.CFrame * CFrame.Angles(0, math.rad(80), 0)}):Play()
  33.     end
  34. end
  35.  
  36. for i, v in pairs(closets) do
  37.     if v:IsA("Model") then
  38.         local playerHiding = nil
  39.         local prompt = v.PromptPart.Prompt
  40.        
  41.         prompt.Triggered:Connect(function(player)
  42.             local character = player.Character
  43.             if not character then return end
  44.            
  45.             if not playerHiding then
  46.                 prompt.Enabled = false
  47.                 playerHiding = player
  48.                 player.Hiding.Value = true
  49.                
  50.                 character:PivotTo(v.InsidePos.CFrame)
  51.                 character.Humanoid.WalkSpeed = 0
  52.                 character.Humanoid.JumpPower = 0
  53.                
  54.                 event:FireClient(player, v)
  55.                 Animation(v, "Enter")
  56.                
  57.                 task.wait(0.7)
  58.                
  59.                 event.OnServerEvent:Connect(function(player, model)
  60.                     if model == v then
  61.                         character:PivotTo(v.OutsidePos.CFrame)
  62.                         Animation(v, "Exit")
  63.                        
  64.                         character.Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
  65.                         character.Humanoid.JumpPower = game.StarterPlayer.CharacterJumpPower
  66.                        
  67.                         task.wait(1.5)
  68.                        
  69.                         prompt.Enabled = true
  70.                         playerHiding = nil
  71.                         player.Hiding.Value = false
  72.                     end
  73.                 end)
  74.             end
  75.         end)
  76.     end
  77. end
  78.  
  79. game.Players.PlayerAdded:Connect(function(player)
  80.     local hiding = Instance.new("BoolValue", player)
  81.     hiding.Name = "Hiding"
  82.     hiding.Value = false
  83. end)
  84.  
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement