I've done this script that when a player touches a brick the camera goes infront of a car model and they have the option to buy it, and when it clicks a textbutton the gui closes and the camera goes back to the player. But, I'm stuck at the part where the camera goes back to the player, because it doesn't follow the player anymore, it just stays at where it changed and doesn't move, so I guess iI have to find the default CFrame. Here is my script:
local gui = script.ScreenGui
local brickTouchedEvent = game.ReplicatedStorage.Events.BrickTouched
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local char = player.Character or player.CharacterAdded:Wait()
brickTouchedEvent.OnClientEvent:Connect(function()
oldCFrame = char.Head.CFrame -- This will set the CFrame before changing
gui.Enabled = true
if camera.CameraType ~= Enum.CameraType.Scriptable then
repeat wait()
camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
end
camera.CFrame = workspace.CameraPart.CFrame
char.Humanoid.WalkSpeed = 0
end)
gui.Frame.TextButton.MouseButton1Click:Connect(function()
camera.CFrame = oldCFrame -- This piece of code right here
char.Humanoid.WalkSpeed = 16
gui.Enabled = false
wait(4)
end)

1 comment
Set CameraType to Custom and set CameraSubject to humanoid to go back. Works for me and there is no cframe work needed