I am trying to make a seat that puts a player's camera at the barrel of a gun, but it can't find out who is sitting in the seat.
This is the localscript in the player's backpack.
local cam = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer.Name
while true do
if _G.PlayerInSeat == player then
cam.CameraSubject = game.Workspace.Vehicle.GunIgnore.Barrel
cam.CameraType = "Attach"
else
--[[cam.CameraSubject = player.Character.Humanoid
cam.CameraType = "Custom"]]
end
wait(0.1)
end
This is the script that detects the player in the seat.
_G.PlayerInSeat = ""
while true do
_G.PlayerInSeat = script.Parent.Occupant.Parent
wait(0.01)
end
Thank you.

3 comments
On line 9 in the local script in the backpack, you need to put, cam.CameraSubject = player.Character:WaitForChild("HumanoidRootPart")
You could clone a local script into the player character?
yes.