So I am trying to build a racing game and I want players to have a first person perspective when in the car which is defined by a part that I am using as my 'camera'. Here is what I've done so far:
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local cam = game.Workspace.CurrentCamera
local camPart = game.Workspace["Lamborghini Aventador-J"].Body.Camera
camPart.Entered.OnClientEvent:Connect(function() --camPart.Entered is a remote event
repeat wait()
cam.CameraType = Enum.CameraType.Scriptable
until cam.CameraType == Enum.CameraType.Scriptable
cam.CFrame = camPart.CFrame
end)
This does work, but the problem is that when we drive the car, the player's camera perspective is left behind and the car drives off with the camPart. I think a good way to solve this might be to detect when the camPart is in motion with the car and set the CFrame of cam to the camPart whenever the script thinks it's moving. I just don't know how I'd detect the camPart moving.
Any ideas?

1 comment
get velocity