Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is the default camera CFrame?

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

2

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

1 answer

✓ Accepted answer

when your done just change camera.CameraTypeto Custom and that will make Camera.CameraSubject the player's humanoid, and camera can be customized as the the player wishes..

7 comments

0

exactly my comment on the question. great minds think alike

0

lol

0

But when I switch the camera to the campart I can rotate the camera, how do I make it so the player can't rotate it?

0

not sure, scriptable cameras don't have turning functionality (at least i think)

1

Oh, I didn't get it right lol, it's supposed to change the camera type to custom when I'm leaving the gui, and I was changing it to set the camera to my camera part xd, so its fixed now.

1

okay cool glad we could help

0

thx @ProqrammedGreen

This discussion is preserved as it was. New answers, comments, and votes are closed.