Advertisement
Yondiux

Camaras script

Jul 13th, 2021
7,489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1.  
  2. -- si quieres agregar mas camaras solo crea mas camaras del la part que creastes, no necesitas ponerle mas codigo obiamente llamando las demas 4, 5, 6 y asi con las que crees.
  3.  
  4. local plr = game.Players.LocalPlayer
  5.  
  6. local char = plr.Character or plr.CharacterAdded:Wait()
  7.  
  8.  
  9. local cam = workspace.CurrentCamera
  10.  
  11.  
  12. local function alphabeticalOrder(instance)
  13.  
  14. local children = instance:GetChildren()
  15.  
  16. table.sort(children, function(c1, c2)
  17.  
  18. return c1.Name:lower() < c2.Name:lower()
  19.  
  20. end)
  21.  
  22. return children
  23.  
  24. end
  25.  
  26. local camParts = alphabeticalOrder(workspace.Cameras)
  27.  
  28.  
  29. local LArrow = script.Parent.LeftArrow
  30.  
  31. local RArrow = script.Parent.RightArrow
  32.  
  33.  
  34. local arrowClickCooldown = false
  35.  
  36.  
  37. char:WaitForChild("Humanoid").Seated:Connect(function(isSeated, seat)
  38.  
  39. if not isSeated or seat.Name ~= "CameraSeat" then
  40.  
  41. script.Parent.LeftArrow.Visible = false
  42. script.Parent.RightArrow.Visible = false
  43.  
  44. cam.CameraType = Enum.CameraType.Custom
  45.  
  46. return
  47. end
  48.  
  49.  
  50. script.Parent.LeftArrow.Visible = true
  51. script.Parent.RightArrow.Visible = true
  52.  
  53.  
  54. cam.CameraType = Enum.CameraType.Scriptable
  55.  
  56. cam.CFrame = camParts[1].CFrame
  57.  
  58.  
  59. local camNumber = 1
  60.  
  61.  
  62. RArrow.MouseButton1Click:Connect(function()
  63. if arrowClickCooldown then return end
  64. arrowClickCooldown = true
  65.  
  66. if camNumber == #camParts then
  67. cam.CFrame = camParts[1].CFrame
  68. camNumber = 1
  69. else
  70. cam.CFrame = camParts[camNumber + 1].CFrame
  71. camNumber = camNumber + 1
  72. end
  73. wait(0.1)
  74. arrowClickCooldown = false
  75. end)
  76.  
  77.  
  78. LArrow.MouseButton1Click:Connect(function()
  79. if arrowClickCooldown then return end
  80. arrowClickCooldown = true
  81. if camNumber == 1 then
  82. cam.CFrame = camParts[#camParts].CFrame
  83. camNumber = #camParts
  84. else
  85. cam.CFrame = camParts[camNumber - 1].CFrame
  86. camNumber = camNumber - 1
  87. end
  88. wait(0.1)
  89. arrowClickCooldown = false
  90. end)
  91. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement