1MinuteRoblox

Camera Security Handler Script V1.0 by 1MinuteRobloxTutorials

Apr 28th, 2024 (edited)
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. -- This script sets up a camera system controlled by arrow buttons when a player is seated.
  2. -- Scripted by 1MinuteRobloxTutorials
  3.  
  4. -- Accessing UI elements and camera positions
  5. local leftArrow = script.Parent.Left
  6. local rightArrow = script.Parent.Right
  7. local camFolder = workspace.CamPositions
  8.  
  9. -- Accessing player and character
  10. local plr = game.Players.LocalPlayer
  11. local char = plr.Character or plr:WaitForChild("Character")
  12. local cam = game.Workspace.CurrentCamera
  13.  
  14. -- Variable to keep track of current camera position
  15. local number = 1
  16.  
  17. -- Connect to the Seated event of the Humanoid to trigger when the player sits down
  18. char:WaitForChild("Humanoid").Seated:Connect(function(Sitting, seat)
  19. -- If the player is not sitting or not in the correct seat, hide arrows and set camera type to Custom
  20. if not Sitting or seat.Name ~= "SecuritySeat" then
  21. leftArrow.Visible = false
  22. rightArrow.Visible = false
  23. cam.CameraType = Enum.CameraType.Custom
  24. return
  25. end
  26.  
  27. -- If sitting in the correct seat, show arrows and set camera type to Scriptable
  28. leftArrow.Visible = true
  29. rightArrow.Visible = true
  30. cam.CameraType = Enum.CameraType.Scriptable
  31. cam.CFrame = workspace.CamPositions["1"].CFrame
  32.  
  33. -- Connect arrow buttons to their respective functions
  34. rightArrow.MouseButton1Click:Connect(function()
  35. -- Update camera position to the next one in the sequence
  36. if number == 3 then -- Change 3 depending on the amount of cameras you have.
  37. cam.CFrame = camFolder["1"].CFrame
  38. number = 1
  39. else
  40. cam.CFrame = camFolder[number +1].CFrame
  41. number = number +1
  42. end
  43. wait(.1)
  44. end)
  45. end)
  46.  
  47. -- Connect left arrow button to its function
  48. leftArrow.MouseButton1Click:Connect(function()
  49. -- Update camera position to the previous one in the sequence
  50. if number == 1 then
  51. cam.CFrame = camFolder["3"].CFrame -- Change 3 depending on the amount of cameras you have.
  52. number = 3
  53. else
  54. cam.CFrame = camFolder[number -1].CFrame
  55. number = number -1
  56. end
  57. wait(.1)
  58. end)
  59.  
Advertisement
Add Comment
Please, Sign In to add comment