Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This script sets up a camera system controlled by arrow buttons when a player is seated.
- -- Scripted by 1MinuteRobloxTutorials
- -- Accessing UI elements and camera positions
- local leftArrow = script.Parent.Left
- local rightArrow = script.Parent.Right
- local camFolder = workspace.CamPositions
- -- Accessing player and character
- local plr = game.Players.LocalPlayer
- local char = plr.Character or plr:WaitForChild("Character")
- local cam = game.Workspace.CurrentCamera
- -- Variable to keep track of current camera position
- local number = 1
- -- Connect to the Seated event of the Humanoid to trigger when the player sits down
- char:WaitForChild("Humanoid").Seated:Connect(function(Sitting, seat)
- -- If the player is not sitting or not in the correct seat, hide arrows and set camera type to Custom
- if not Sitting or seat.Name ~= "SecuritySeat" then
- leftArrow.Visible = false
- rightArrow.Visible = false
- cam.CameraType = Enum.CameraType.Custom
- return
- end
- -- If sitting in the correct seat, show arrows and set camera type to Scriptable
- leftArrow.Visible = true
- rightArrow.Visible = true
- cam.CameraType = Enum.CameraType.Scriptable
- cam.CFrame = workspace.CamPositions["1"].CFrame
- -- Connect arrow buttons to their respective functions
- rightArrow.MouseButton1Click:Connect(function()
- -- Update camera position to the next one in the sequence
- if number == 3 then -- Change 3 depending on the amount of cameras you have.
- cam.CFrame = camFolder["1"].CFrame
- number = 1
- else
- cam.CFrame = camFolder[number +1].CFrame
- number = number +1
- end
- wait(.1)
- end)
- end)
- -- Connect left arrow button to its function
- leftArrow.MouseButton1Click:Connect(function()
- -- Update camera position to the previous one in the sequence
- if number == 1 then
- cam.CFrame = camFolder["3"].CFrame -- Change 3 depending on the amount of cameras you have.
- number = 3
- else
- cam.CFrame = camFolder[number -1].CFrame
- number = number -1
- end
- wait(.1)
- end)
Advertisement
Add Comment
Please, Sign In to add comment