Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- SERVER SCRIPT --
- local tweenSerice = game:GetService("TweenService")
- local replicatedStorage = game:GetService("ReplicatedStorage")
- local event = replicatedStorage:WaitForChild("HideEvent")
- local closets = script.Parent:GetChildren()
- local function Animation(model, action)
- local hinge1 = model:WaitForChild("Hinge1")
- local hinge2 = model:WaitForChild("Hinge2")
- if action == "Exit" then
- local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
- tweenSerice:Create(hinge1, tweenInfo, {CFrame = hinge1.CFrame * CFrame.Angles(0, math.rad(80), 0)}):Play()
- tweenSerice:Create(hinge2, tweenInfo, {CFrame = hinge2.CFrame * CFrame.Angles(0, math.rad(-80), 0)}):Play()
- task.wait(tweenInfo.Time)
- local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
- tweenSerice:Create(hinge1, tweenInfo, {CFrame = hinge1.CFrame * CFrame.Angles(0, math.rad(-100), 0)}):Play()
- tweenSerice:Create(hinge2, tweenInfo, {CFrame = hinge2.CFrame * CFrame.Angles(0, math.rad(100), 0)}):Play()
- elseif action == "Enter" then
- local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
- tweenSerice:Create(hinge1, tweenInfo, {CFrame = hinge1.CFrame * CFrame.Angles(0, math.rad(100), 0)}):Play()
- tweenSerice:Create(hinge2, tweenInfo, {CFrame = hinge2.CFrame * CFrame.Angles(0, math.rad(-100), 0)}):Play()
- task.wait(tweenInfo.Time)
- local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
- tweenSerice:Create(hinge1, tweenInfo, {CFrame = hinge1.CFrame * CFrame.Angles(0, math.rad(-80), 0)}):Play()
- tweenSerice:Create(hinge2, tweenInfo, {CFrame = hinge2.CFrame * CFrame.Angles(0, math.rad(80), 0)}):Play()
- end
- end
- for i, v in pairs(closets) do
- if v:IsA("Model") then
- local playerHiding = nil
- local prompt = v.PromptPart.Prompt
- prompt.Triggered:Connect(function(player)
- local character = player.Character
- if not character then return end
- if not playerHiding then
- prompt.Enabled = false
- playerHiding = player
- player.Hiding.Value = true
- character:PivotTo(v.InsidePos.CFrame)
- character.Humanoid.WalkSpeed = 0
- character.Humanoid.JumpPower = 0
- event:FireClient(player, v)
- Animation(v, "Enter")
- task.wait(0.7)
- event.OnServerEvent:Connect(function(player, model)
- if model == v then
- character:PivotTo(v.OutsidePos.CFrame)
- Animation(v, "Exit")
- character.Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
- character.Humanoid.JumpPower = game.StarterPlayer.CharacterJumpPower
- task.wait(1.5)
- prompt.Enabled = true
- playerHiding = nil
- player.Hiding.Value = false
- end
- end)
- end
- end)
- end
- end
- game.Players.PlayerAdded:Connect(function(player)
- local hiding = Instance.new("BoolValue", player)
- hiding.Name = "Hiding"
- hiding.Value = false
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement