Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 1 скрипт в workspace elevator ну или короче чекайте видео --
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local ServerScriptService = game:GetService("ServerScriptService")
- local TeleportService = game:GetService("TeleportService")
- local SafeTeleport = require(ServerScriptService.SafeTeleport)
- local movingEvent = ReplicatedStorage:WaitForChild("MovingElevator")
- local elevatorEvent = ReplicatedStorage:WaitForChild("Elevator")
- local elevator = script.Parent
- local prismatic = elevator.Shaft.PrismaticConstraint
- local gui = elevator.Screen.SurfaceGui
- local config = elevator.Config
- local playersWaiting = {}
- local countdownRunning = false
- local moving = false
- local function Setup()
- playersWaiting = {}
- moving = false
- gui.Title.Text = #playersWaiting .. "/" .. config.MaxPlayers.Value .. " Players"
- gui.Status.Text = "Waiting..."
- end
- local function TeleportPlayers()
- local placeId = 0 -- свой айди вставьте
- local server = TeleportService:ReserveServer(placeId)
- local options = Instance.new("TeleportOptions")
- options.ReservedServerAccessCode = server
- SafeTeleport(placeId, playersWaiting, options)
- print("Finished teleport")
- end
- local function MoveElevator()
- moving = true
- for i, player in pairs(playersWaiting) do
- movingEvent:FireClient(player)
- end
- gui.Status.Text = "Teleporting Players..."
- prismatic.TargetPosition = -20
- TeleportPlayers()
- task.wait(10)
- prismatic.TargetPosition = 0
- task.wait(8)
- Setup()
- end
- local function RunCountdown()
- countdownRunning = true
- for i=10, 1, -1 do
- gui.Status.Text = "Starting in: " .. i
- task.wait(1)
- if #playersWaiting < 1 then
- countdownRunning = false
- Setup()
- return
- end
- end
- MoveElevator()
- countdownRunning = false
- end
- elevator.Entrance.Touched:Connect(function(part)
- local player = Players:GetPlayerFromCharacter(part.Parent)
- local isWaiting = table.find(playersWaiting, player)
- if player and not isWaiting and #playersWaiting < config.MaxPlayers.Value and not moving then
- table.insert(playersWaiting, player)
- gui.Title.Text = #playersWaiting .. "/" .. config.MaxPlayers.Value .. " Players"
- player.Character.PrimaryPart.CFrame = elevator.TeleportIn.CFrame
- elevatorEvent:FireClient(player, elevator)
- if not countdownRunning then
- RunCountdown()
- end
- end
- end)
- elevatorEvent.OnServerEvent:Connect(function(player)
- local isWaiting = table.find(playersWaiting, player)
- if isWaiting then
- table.remove(playersWaiting, isWaiting)
- end
- gui.Title.Text = #playersWaiting .. "/" .. config.MaxPlayers.Value .. " Players"
- if player.Character then
- player.Character.PrimaryPart.CFrame = elevator.TeleportOut.CFrame
- end
- end)
- -- 2 скрипт в serverscriptservice --
- local TeleportService = game:GetService("TeleportService")
- local ATTEMPT_LIMIT = 5
- local RETRY_DELAY = 1
- local FLOOD_DELAY = 15
- local function SafeTeleport(placeId, players, options)
- local attemptIndex = 0
- local success, result -- define pcall results outside of loop so results can be reported later on
- repeat
- success, result = pcall(function()
- return TeleportService:TeleportAsync(placeId, players, options) -- teleport the player in a protected call to prevent erroring
- end)
- attemptIndex += 1
- if not success then
- task.wait(RETRY_DELAY)
- end
- until success or attemptIndex == ATTEMPT_LIMIT -- stop trying to teleport if call was successful, or if retry limit has been reached
- if not success then
- warn(result) -- print the failure reason to output
- end
- return success, result
- end
- local function handleFailedTeleport(player, teleportResult, errorMessage, targetPlaceId, teleportOptions)
- if teleportResult == Enum.TeleportResult.Flooded then
- task.wait(FLOOD_DELAY)
- elseif teleportResult == Enum.TeleportResult.Failure then
- task.wait(RETRY_DELAY)
- else
- -- if the teleport is invalid, don't retry, just report the error
- error(("Invalid teleport [%s]: %s"):format(teleportResult.Name, errorMessage))
- end
- SafeTeleport(targetPlaceId, {player}, teleportOptions)
- end
- TeleportService.TeleportInitFailed:Connect(handleFailedTeleport)
- return SafeTeleport
- -- 3 скрипт в starter gui elevator --
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local tweenservice = game:GetService("TweenService")
- local movingEvent = ReplicatedStorage:WaitForChild("MovingElevator")
- local elevatorEvent = ReplicatedStorage:WaitForChild("Elevator")
- local gui = script.Parent
- local exitBtn = gui.Exit
- local camera = workspace.CurrentCamera
- local playerrrr = game.Players.LocalPlayer.PlayerGui.Elevator.TextLabel
- movingEvent.OnClientEvent:Connect(function()
- exitBtn.Visible = false
- end)
- elevatorEvent.OnClientEvent:Connect(function(elevator)
- exitBtn.Visible = true
- camera.CameraType = Enum.CameraType.Scriptable
- camera.CFrame = elevator.Camera.CFrame
- script.Parent.TextLabel.Visible = true
- wait(8)
- playerrrr.Text = "New Focusing camera 3"
- wait(1)
- playerrrr.Text = "New Focusing camera 2"
- wait(1)
- playerrrr.Text = "New Focusing camera 1"
- wait(1)
- playerrrr.Text = "New Focusing camera 0"
- wait(0.05)
- playerrrr.TextTransparency = 0.1 wait(0.01)
- playerrrr.TextTransparency = 0.2 wait(0.01)
- playerrrr.TextTransparency = 0.3 wait(0.01)
- playerrrr.TextTransparency = 0.4 wait(0.01)
- playerrrr.TextTransparency = 0.5 wait(0.01)
- playerrrr.TextTransparency = 0.6 wait(0.01)
- playerrrr.TextTransparency = 0.7 wait(0.01)
- playerrrr.TextTransparency = 0.8 wait(0.01)
- playerrrr.TextTransparency = 0.9 wait(0.01)
- playerrrr.TextTransparency = 1 wait(0.01)
- wait(0.13)
- script.Parent.TextLabel.Visible = false
- if script.Parent.TextLabel.Visible == false then
- workspace:WaitForChild("Elevator"):WaitForChild("Camera").Position = Vector3.new(-6.289, 13.67, -88.384)
- camera.CameraType = Enum.CameraType.Scriptable
- camera.CFrame = elevator.Camera.CFrame
- end
- end)
- exitBtn.Activated:Connect(function()
- local player = game.Players.LocalPlayer
- workspace:WaitForChild("Elevator"):WaitForChild("Camera").Position = Vector3.new(-6.289, 31.382, -86.539)
- exitBtn.Visible = false
- camera.CameraType = Enum.CameraType.Custom
- camera.CameraSubject = player.Character.Humanoid
- elevatorEvent:FireServer()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement