Hey developers.
How would I be able to do a locked first-person camera view of a moving part? Ask questions if you need more information!! :D
You could just set the CameraType to Scriptable, set the CFrame to the Part, then detect when the Part moves using a RunService .RenderStepped loop perhaps?
local Cam = workspace.CurrentCamera
local RunService = game:GetService("RunService")
local Part = workspace.MovingPart
wait(1) --Adding this cause Camera Module Warning haha funny
Cam.CameraType = Enum.CameraType.Scriptable
RunService.RenderStepped:Connect(function()
Cam.CFrame = Part.CFrame
end)
Keeping in mind that you are only able to access the Local Player’s Camera using a LocalScript, so it should belong inside StarterPlayerScripts for it to work
gotcha, and i can just hook these up to functions if i wanted to switch views?
You could set the CameraType back to “Custom” which would send it back to where the Character’s Camera should be I believe
I meant between different moving parts, haha. sorry about the unclear message.
Ah I gotcha
Well, it would depend on the scenario you could be going for but say you wanted to switch between 2 MovingParts every 3 seconds or so, we could do something like this:
local Cam = workspace.CurrentCamera
local RunService = game:GetService("RunService")
local Part = workspace.MovingPart
local Part2 = workspace.MovingPart2
wait(1) --Adding this cause Camera Module Warning haha funny
Cam.CameraType = Enum.CameraType.Scriptable
while true do
Cam.CFrame = Part.CFrame
wait(3)
Cam.CFrame = Part2.CFrame
wait(3)
end
You could just encase some kind of loop so that it keeps switching in-between mparts
Gotcha, thanks! Helped a lot. ![]()