How can I change this code to reset the players camera

I made a camera based menu for my game but I wanted to add a feature were pressing the play button would but the camera back to the players cam Ive already made it make the menu ui invisible and remove the blur on the camera I just need it to go back to the players view and I can figure it out

heres the code

local currentcam = workspace.CurrentCamera

local campart = workspace.CamPart

local playbutton = script.Parent.Play

wait(0.001)

currentcam.CameraType = Enum.CameraType.Scriptable

currentcam.CFrame = campart.CFrame

local function playEntered()
	currentcam.CFrame = campart.CFrame
end

playbutton.MouseButton1Click:Connect(playEntered)

I can provide a picture of the menu for reference if needed

I think this will reset the camera back to the player.

currentcam.CameraType = Enum.CameraType.Fixed

sry for the late reply Im not getting notificatoins for some reason

but were in the script would I put this?

local camera = workspace.CurrentCamera
local camPart = workspace:WaitForChild("CamPart")
local playButton = script.Parent.Play


local connections = {}
table.insert(connections, camera:GetPropertyChangedSignal("CameraType"):Connect(function()
	if camera.CameraType ~= Enum.CameraType.Scriptable then
		camera.CameraType = Enum.CameraType.Scriptable
	end
end))

table.insert(connections, camera:GetPropertyChangedSignal("CFrame"):Connect(function()
	if camera.CFrame ~= camPart.CFrame then
		camera.CFrame = camPart.CFrame
	end
end))


playButton.MouseButton1Click:Connect(function()
	local Character = game.Players.LocalPlayer.Character
	if not Character then return end
	local Humanoid = Character.Humanoid
	if not Humanoid then return end
	for i, v in pairs(connections) do v:Disconnect() end
	camera.CameraType = Enum.CameraType.Custom
	camera.CameraSubject = Humanoid 
end)
2 Likes

sorry for the late reply

it doesn’t seem to work though I put it into the Play button and it didnt do anything

It works for me, check that your variables are correct

Make sure its a localscript as well

1 Like

inside the play button right?

sure… just change this “local playButton = script.Parent.Play” to be “local playButton = script.Parent”

1 Like

WORKS TYSM

i just changed some of the varibles for the workspace to game.workspace it works now though thank you so much for the help I spent all day trying to figure this out lol

1 Like