I made this script that will allow the user to click a button between camera views. I have that system done, however when I attach the camera to a vehicle and then go to a camera view the camera stays where it is at the time of pressing the button as shown in the video, here is the script aswell.
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local CamFolder = script.Parent.CamFolder.Value
local GearCam = CamFolder.Gear
local TailCam = CamFolder.Tail
local TailWingLeftCam = CamFolder.TailWingLeft
local TailWingRightCam = CamFolder.TailWingRight
local GearButton = script.Parent.Frame.Gears
local TailButton = script.Parent.Frame.Tail
local TailWingLeftButton = script.Parent.Frame.TailWingLeft
local TailWingRightButton = script.Parent.Frame.TailWingRight
local Reset = script.Parent.Reset
local BlackFrame = script.Parent.Parent.Frame
GearButton.MouseButton1Click:Connect(function()
wait(0.25)
--[[ for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency - 0.05
wait(0.1)
end
]]
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = GearCam.CFrame
wait(2)
--[[for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency + 0.05
wait(0.1)
end]]
end)
TailButton.MouseButton1Click:Connect(function()
wait(0.25)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency - 0.05
wait(0.1)
end
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = TailCam.CFrame
wait(2)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency + 0.05
wait(0.1)
end
end)
TailWingLeftButton.MouseButton1Click:Connect(function()
wait(0.25)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency - 0.05
wait(0.1)
end
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = TailWingLeftCam.CFrame
wait(2)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency + 0.05
wait(0.1)
end
end)
TailWingRightButton.MouseButton1Click:Connect(function()
wait(0.25)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency - 0.05
wait(0.1)
end
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = TailWingRightCam.CFrame
wait(2)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency + 0.05
wait(0.1)
end
end)
script.Parent.Reset.MouseButton1Click:Connect(function()
wait(0.25)
--[[ for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency - 0.05
wait(0.1)
end]]
repeat wait()
Camera.CameraType = Enum.CameraType.Custom
until Camera.CameraType == Enum.CameraType.Custom
Camera.CFrame = Character.Head.CFrame
wait(2)
--[[ for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency + 0.05
wait(0.1)
end]]
end)
If anyone can provide a solution it’d be great. My theory of why the camera doesnt stay with the part, would be where it uses a CFrame, but i have no idea how i’d go around that.
After reading it, this is what I managed to get constructed
local RunService = game:GetService("RunService")
GearButton.MouseButton1Click:Connect(function()
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
RunService:BindToRenderStep("GearBinding",1, Camera.CFrame = GearCam.CFrame)
end)
However im quite confused as i get an error line underneath the = sign saying that it was expecting to close the line there, im realy confused on this so any help is appriciated, thank you.
So I now have the issue where the camera bugs out and wont allow me to move it, but that I mean it just snaps back to view my character as normal as soon as I press the reset button on the gui, if you need a video I can take one but yea it wont allow me to move the camera without it snapping back to where it was.
The entire script now
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local RunService = game:GetService("RunService")
local CamFolder = script.Parent.CamFolder.Value
local GearCam = CamFolder.Gear
local TailCam = CamFolder.Tail
local TailWingLeftCam = CamFolder.TailWingLeft
local TailWingRightCam = CamFolder.TailWingRight
local GearButton = script.Parent.Frame.Gears
local TailButton = script.Parent.Frame.Tail
local TailWingLeftButton = script.Parent.Frame.TailWingLeft
local TailWingRightButton = script.Parent.Frame.TailWingRight
local Reset = script.Parent.Reset
local BlackFrame = script.Parent.Parent.Frame
local function SetGearCamCFrame()
Camera.CFrame = GearCam.CFrame
end
local function SetTailCamCFrame()
Camera.CFrame = TailCam.CFrame
end
local function SetLeftTailWingCamCFrame()
Camera.CFrame = TailWingLeftCam.CFrame
end
local function SetRightTailWingCamCFrame()
Camera.CFrame = TailWingRightCam.CFrame
end
GearButton.MouseButton1Click:Connect(function()
wait(0.25)
--[[ for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency - 0.05
wait(0.1)
end
]]
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
RunService:BindToRenderStep("GearBinding",1, SetGearCamCFrame)
--[[for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency + 0.05
wait(0.1)
end]]
end)
TailButton.MouseButton1Click:Connect(function()
wait(0.25)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency - 0.05
wait(0.1)
end
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
RunService:BindToRenderStep("TailBinding",1, SetTailCamCFrame)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency + 0.05
wait(0.1)
end
end)
TailWingLeftButton.MouseButton1Click:Connect(function()
wait(0.25)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency - 0.05
wait(0.1)
end
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
RunService:BindToRenderStep("SetLeftTailWingBinding",1, SetLeftTailWingCamCFrame)
wait(2)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency + 0.05
wait(0.1)
end
end)
TailWingRightButton.MouseButton1Click:Connect(function()
wait(0.25)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency - 0.05
wait(0.1)
end
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
RunService:BindToRenderStep("SetRightTailWingBinding",1, SetRightTailWingCamCFrame)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency + 0.05
wait(0.1)
end
end)
script.Parent.Reset.MouseButton1Click:Connect(function()
wait(0.25)
--[[ for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency - 0.05
wait(0.1)
end]]
RunService:UnbindFromRenderStep(SetGearCamCFrame)
RunService:UnbindFromRenderStep(SetTailCamCFrame)
RunService:UnbindFromRenderStep(SetLeftTailWingCamCFrame)
RunService:UnbindFromRenderStep(SetRightTailWingCamCFrame)
repeat wait()
Camera.CameraType = Enum.CameraType.Custom
until Camera.CameraType == Enum.CameraType.Custom
Camera.CFrame = Character.Head.CFrame
wait(2)
--[[ for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency + 0.05
wait(0.1)
end]]
end)
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local RunService = game:GetService("RunService")
local CamFolder = script.Parent.CamFolder.Value
local GearCam = CamFolder.Gear
local TailCam = CamFolder.Tail
local TailWingLeftCam = CamFolder.TailWingLeft
local TailWingRightCam = CamFolder.TailWingRight
local GearButton = script.Parent.Frame.Gears
local TailButton = script.Parent.Frame.Tail
local TailWingLeftButton = script.Parent.Frame.TailWingLeft
local TailWingRightButton = script.Parent.Frame.TailWingRight
local Reset = script.Parent.Reset
local BlackFrame = script.Parent.Parent.Frame
local function SetGearCamCFrame()
Camera.CFrame = GearCam.CFrame
end
local function SetTailCamCFrame()
Camera.CFrame = TailCam.CFrame
end
local function SetLeftTailWingCamCFrame()
Camera.CFrame = TailWingLeftCam.CFrame
end
local function SetRightTailWingCamCFrame()
Camera.CFrame = TailWingRightCam.CFrame
end
GearButton.MouseButton1Click:Connect(function()
wait(0.25)
--[[ for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency - 0.05
wait(0.1)
end
]]
repeat task.wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
RunService:BindToRenderStep("GearBinding",1, SetGearCamCFrame)
--[[for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency + 0.05
wait(0.1)
end]]
end)
TailButton.MouseButton1Click:Connect(function()
wait(0.25)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency - 0.05
wait(0.1)
end
repeat task.wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
RunService:BindToRenderStep("TailBinding",1, SetTailCamCFrame)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency + 0.05
wait(0.1)
end
end)
TailWingLeftButton.MouseButton1Click:Connect(function()
wait(0.25)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency - 0.05
wait(0.1)
end
repeat task.wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
RunService:BindToRenderStep("SetLeftTailWingBinding",1, SetLeftTailWingCamCFrame)
wait(2)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency + 0.05
wait(0.1)
end
end)
TailWingRightButton.MouseButton1Click:Connect(function()
wait(0.25)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency - 0.05
wait(0.1)
end
repeat task.wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
RunService:BindToRenderStep("SetRightTailWingBinding",1, SetRightTailWingCamCFrame)
for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency + 0.05
wait(0.1)
end
end)
script.Parent.Reset.MouseButton1Click:Connect(function()
wait(0.25)
--[[ for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency - 0.05
wait(0.1)
end]]
RunService:UnbindFromRenderStep(SetGearCamCFrame)
RunService:UnbindFromRenderStep(SetTailCamCFrame)
RunService:UnbindFromRenderStep(SetLeftTailWingCamCFrame)
RunService:UnbindFromRenderStep(SetRightTailWingCamCFrame)
repeat task.wait()
Camera.CameraType = Enum.CameraType.Custom
until Camera.CameraType == Enum.CameraType.Custom
Camera.CFrame = Character.Head.CFrame
wait(2)
--[[ for i =1,18 do
BlackFrame.Transparency = BlackFrame.Transparency + 0.05
wait(0.1)
end]]
end)
If you want the default camera system to take back over once the transition is complete, you net to set the CameraType back to ‘Custom’ or another trackable enum camera type.
Also, don’t forget to correctly set the CameraSubject.
As mentioned above you could also just go about manually setting the CFrame of the camera, but this means creating your own camera system, orientation and flow which may have a lot of problems down the line.
Again, if you want to restore the default camera settings, to just CameraType and CameraSubject
Make sure that the character is loaded first before running the repeat until loop, you can achieve this by using the CharacterAdded:Wait() function at top of your code.
When trying to set back the camera to normal or default, the CameraType property has to be Custom, and the CameraSubject property has to be the character’s Humanoid.