Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can a manipulate a player's camera when they sit in a seat? [SOLVED]

Asked by 6 years ago
Edited 6 years ago

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.

0
On line 9 in the local script in the backpack, you need to put, cam.CameraSubject = player.Character:WaitForChild("HumanoidRootPart") saSlol2436 716 — 6y
1
You could clone a local script into the player character? User#5423 17 — 6y
0
yes. JarFullOfMayonnaise 48 — 6y

Answer this question