I have made a post similarly to this earlier in the day about the player’s camera tweening to a specific location upon sitting in a seat. While my previous issue has been solved, I have encountered a new one when I was making modifications. As stated: I had made a system where the player’s camera would tween to a specific location upon sitting on a specific seat. Upon realizing that I wanted to have more seats in the game, I hit a roadblock when I realized that I would have to manually acquired each seat and the camera it is attached to, which isn’t efficient at all. So as an alternative to a single LocalScript inside of the StarterGui to control all of the cameras at once, I assumed that it would be better to control the camera from within the seat itself. The code works as expected for only one player. When other players join and sit in the other seats, however, it causes the player with the working camera to revert back to default. So the overall issue is that only one player at a time that is seated will have the working camera positioning. For the script I currently have, it is a regular script with a client run context, and it is inside of every seat present in my game. My apologies if this is a long read. Hopeful to hear any response.
-- Get services
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
-- Get the player
local player = Players.LocalPlayer
-- Get instances
local seat = script.Parent
local monitorCamera = seat:WaitForChild("MonitorCamera")
local currentCamera = workspace.CurrentCamera
-- Set tween
local cameraTween = TweenService:Create(currentCamera, TweenInfo.new(1.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut), {CFrame = monitorCamera.CFrame})
-- Function to change the player's camera upon sitting down
local function updateCamera()
if seat.Occupant and seat.Occupant.Parent == player.Character then
currentCamera.CameraType = Enum.CameraType.Scriptable
cameraTween:Play()
else
currentCamera.CameraType = Enum.CameraType.Custom
end
end
seat:GetPropertyChangedSignal("Occupant"):Connect(updateCamera)
-- Check if the player is sitting on game start
updateCamera()