Advertisement
Timon-Gun

скрипты ттд 4 части кому надо

Oct 8th, 2023
1,977
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.28 KB | None | 0 0
  1. -- 1 скрипт в workspace elevator ну или короче чекайте видео --
  2. local Players = game:GetService("Players")
  3. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  4. local ServerScriptService = game:GetService("ServerScriptService")
  5. local TeleportService = game:GetService("TeleportService")
  6.  
  7. local SafeTeleport = require(ServerScriptService.SafeTeleport)
  8.  
  9. local movingEvent = ReplicatedStorage:WaitForChild("MovingElevator")
  10. local elevatorEvent = ReplicatedStorage:WaitForChild("Elevator")
  11. local elevator = script.Parent
  12. local prismatic = elevator.Shaft.PrismaticConstraint
  13. local gui = elevator.Screen.SurfaceGui
  14. local config = elevator.Config
  15. local playersWaiting = {}
  16. local countdownRunning = false
  17. local moving = false
  18.  
  19. local function Setup()
  20. playersWaiting = {}
  21. moving = false
  22. gui.Title.Text = #playersWaiting .. "/" .. config.MaxPlayers.Value .. " Players"
  23. gui.Status.Text = "Waiting..."
  24. end
  25.  
  26. local function TeleportPlayers()
  27. local placeId = 0 -- свой айди вставьте
  28. local server = TeleportService:ReserveServer(placeId)
  29. local options = Instance.new("TeleportOptions")
  30. options.ReservedServerAccessCode = server
  31. SafeTeleport(placeId, playersWaiting, options)
  32. print("Finished teleport")
  33. end
  34.  
  35. local function MoveElevator()
  36. moving = true
  37. for i, player in pairs(playersWaiting) do
  38. movingEvent:FireClient(player)
  39. end
  40. gui.Status.Text = "Teleporting Players..."
  41. prismatic.TargetPosition = -20
  42. TeleportPlayers()
  43. task.wait(10)
  44. prismatic.TargetPosition = 0
  45. task.wait(8)
  46. Setup()
  47. end
  48.  
  49. local function RunCountdown()
  50. countdownRunning = true
  51. for i=10, 1, -1 do
  52. gui.Status.Text = "Starting in: " .. i
  53. task.wait(1)
  54. if #playersWaiting < 1 then
  55. countdownRunning = false
  56. Setup()
  57. return
  58. end
  59. end
  60. MoveElevator()
  61. countdownRunning = false
  62. end
  63.  
  64. elevator.Entrance.Touched:Connect(function(part)
  65. local player = Players:GetPlayerFromCharacter(part.Parent)
  66. local isWaiting = table.find(playersWaiting, player)
  67.  
  68. if player and not isWaiting and #playersWaiting < config.MaxPlayers.Value and not moving then
  69. table.insert(playersWaiting, player)
  70. gui.Title.Text = #playersWaiting .. "/" .. config.MaxPlayers.Value .. " Players"
  71. player.Character.PrimaryPart.CFrame = elevator.TeleportIn.CFrame
  72. elevatorEvent:FireClient(player, elevator)
  73. if not countdownRunning then
  74. RunCountdown()
  75. end
  76. end
  77. end)
  78.  
  79. elevatorEvent.OnServerEvent:Connect(function(player)
  80. local isWaiting = table.find(playersWaiting, player)
  81. if isWaiting then
  82. table.remove(playersWaiting, isWaiting)
  83. end
  84.  
  85. gui.Title.Text = #playersWaiting .. "/" .. config.MaxPlayers.Value .. " Players"
  86.  
  87. if player.Character then
  88. player.Character.PrimaryPart.CFrame = elevator.TeleportOut.CFrame
  89. end
  90. end)
  91.  
  92. -- 2 скрипт в serverscriptservice --
  93. local TeleportService = game:GetService("TeleportService")
  94.  
  95. local ATTEMPT_LIMIT = 5
  96. local RETRY_DELAY = 1
  97. local FLOOD_DELAY = 15
  98.  
  99. local function SafeTeleport(placeId, players, options)
  100. local attemptIndex = 0
  101. local success, result -- define pcall results outside of loop so results can be reported later on
  102.  
  103. repeat
  104. success, result = pcall(function()
  105. return TeleportService:TeleportAsync(placeId, players, options) -- teleport the player in a protected call to prevent erroring
  106. end)
  107. attemptIndex += 1
  108. if not success then
  109. task.wait(RETRY_DELAY)
  110. end
  111. until success or attemptIndex == ATTEMPT_LIMIT -- stop trying to teleport if call was successful, or if retry limit has been reached
  112.  
  113. if not success then
  114. warn(result) -- print the failure reason to output
  115. end
  116.  
  117. return success, result
  118. end
  119.  
  120. local function handleFailedTeleport(player, teleportResult, errorMessage, targetPlaceId, teleportOptions)
  121. if teleportResult == Enum.TeleportResult.Flooded then
  122. task.wait(FLOOD_DELAY)
  123. elseif teleportResult == Enum.TeleportResult.Failure then
  124. task.wait(RETRY_DELAY)
  125. else
  126. -- if the teleport is invalid, don't retry, just report the error
  127. error(("Invalid teleport [%s]: %s"):format(teleportResult.Name, errorMessage))
  128. end
  129.  
  130. SafeTeleport(targetPlaceId, {player}, teleportOptions)
  131. end
  132.  
  133. TeleportService.TeleportInitFailed:Connect(handleFailedTeleport)
  134.  
  135. return SafeTeleport
  136. -- 3 скрипт в starter gui elevator --
  137. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  138. local tweenservice = game:GetService("TweenService")
  139. local movingEvent = ReplicatedStorage:WaitForChild("MovingElevator")
  140. local elevatorEvent = ReplicatedStorage:WaitForChild("Elevator")
  141. local gui = script.Parent
  142. local exitBtn = gui.Exit
  143. local camera = workspace.CurrentCamera
  144. local playerrrr = game.Players.LocalPlayer.PlayerGui.Elevator.TextLabel
  145.  
  146. movingEvent.OnClientEvent:Connect(function()
  147. exitBtn.Visible = false
  148. end)
  149.  
  150. elevatorEvent.OnClientEvent:Connect(function(elevator)
  151. exitBtn.Visible = true
  152. camera.CameraType = Enum.CameraType.Scriptable
  153. camera.CFrame = elevator.Camera.CFrame
  154. script.Parent.TextLabel.Visible = true
  155. wait(8)
  156. playerrrr.Text = "New Focusing camera 3"
  157. wait(1)
  158. playerrrr.Text = "New Focusing camera 2"
  159. wait(1)
  160. playerrrr.Text = "New Focusing camera 1"
  161. wait(1)
  162. playerrrr.Text = "New Focusing camera 0"
  163. wait(0.05)
  164. playerrrr.TextTransparency = 0.1 wait(0.01)
  165. playerrrr.TextTransparency = 0.2 wait(0.01)
  166. playerrrr.TextTransparency = 0.3 wait(0.01)
  167. playerrrr.TextTransparency = 0.4 wait(0.01)
  168. playerrrr.TextTransparency = 0.5 wait(0.01)
  169. playerrrr.TextTransparency = 0.6 wait(0.01)
  170. playerrrr.TextTransparency = 0.7 wait(0.01)
  171. playerrrr.TextTransparency = 0.8 wait(0.01)
  172. playerrrr.TextTransparency = 0.9 wait(0.01)
  173. playerrrr.TextTransparency = 1 wait(0.01)
  174. wait(0.13)
  175. script.Parent.TextLabel.Visible = false
  176. if script.Parent.TextLabel.Visible == false then
  177. workspace:WaitForChild("Elevator"):WaitForChild("Camera").Position = Vector3.new(-6.289, 13.67, -88.384)
  178. camera.CameraType = Enum.CameraType.Scriptable
  179. camera.CFrame = elevator.Camera.CFrame
  180. end
  181. end)
  182.  
  183.  
  184. exitBtn.Activated:Connect(function()
  185. local player = game.Players.LocalPlayer
  186. workspace:WaitForChild("Elevator"):WaitForChild("Camera").Position = Vector3.new(-6.289, 31.382, -86.539)
  187. exitBtn.Visible = false
  188. camera.CameraType = Enum.CameraType.Custom
  189. camera.CameraSubject = player.Character.Humanoid
  190.  
  191. elevatorEvent:FireServer()
  192.  
  193. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement