Need help with menu camera

So i used this script

local screenUI = script.Parent
local TweenService = game:GetService(“TweenService”)
local tweenInfo1 = TweenInfo.new(.05, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local camera = workspace.CurrentCamera
local mouse = game:GetService(“Players”).LocalPlayer:GetMouse()
local rs = game:GetService(“RunService”)
local incus = true

repeat wait()
camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
camera.CFrame = workspace.Cam.CFrame

local maxTilt = 10
game:GetService(“RunService”).RenderStepped:Connect(function()
if incus == true then
TweenService:Create(camera,tweenInfo1,{CFrame = workspace.Cam.CFrame * CFrame.Angles(math.rad((((
mouse.Y - mouse.ViewSizeY / 2) / mouse.ViewSizeY)) * -maxTilt),math.rad(((
(mouse.X - mouse.ViewSizeX / 2) / mouse.ViewSizeX)) * -maxTilt),0)}):Play()
end
end)
while true do
game:GetService(‘Players’).PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild(“Humanoid”).Died:Connect(function()
wait(3)
incus = false
repeat wait()
camera.CameraType = Enum.CameraType.Custom
until camera.CameraType == Enum.CameraType.Custom

		end)
	end)
end)
end

script.Parent.Menu.MainFrame.Buttons.PlayButton.Content.Button.MouseButton1Down:Connect(function()
wait(1)

incus = false
repeat wait()
	camera.CameraType = Enum.CameraType.Custom
until camera.CameraType == Enum.CameraType.Custom
camera.CFrame = camera.CFrame
game.Lighting.ColorCorrection.Enabled = false

game.Lighting.ColorCorrection.Enabled = false
wait()
script.Disabled = true

end)

and when i die i my camera comes back to the menu screen which i dont want

1 Like

First of all, please use the code section when showing code on the form, it’s hard to read otherwise, here is an example of what i mean:

type or paste code here

Second of all, i can tell the script is located in a GUI.
The GUI has an option called ResetOnSpawn

If it’s enabled, just tick it off in the properties panel.

image

1 Like

This is what I used for my menu. I created remote events that I could fire when I need to, for example player is exiting menu, or player is opening menu again.

Player script

local replicatedStorage = game:GetService("ReplicatedStorage")
local workSpace = game:GetService("Workspace")

local player = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local isInMenu = script.isInMenu
local cameraPart = workSpace.GameMenu:WaitForChild("GameMenuCamera")

local blur = Instance.new("BlurEffect")
blur.Parent = camera
blur.Size = 40

replicatedStorage.CameraFolder.MenuCamera.OnClientEvent:Connect(function()
	blur.Enabled = true
	isInMenu.Value = true
end)

replicatedStorage.CameraFolder.PlayerCamera.OnClientEvent:Connect(function()
	blur.Enabled = false
	isInMenu.Value = false
	wait(0)
	camera.CFrame = game.Workspace:WaitForChild(player.Name).HumanoidRootPart.CFrame
end)

game:GetService("RunService").RenderStepped:Connect(function()
	if isInMenu.Value == true then
		camera.CFrame = cameraPart.CFrame
	end
end)

It also rotated camera while in menu, because camera.CFrame was moving to the GameMenuCamera position which I made rotating. This will only allow you to fire it only from server, that why I also made server side script, so you could change camera from client side.

Server script

local replicatedStorage = game:GetService("ReplicatedStorage")

replicatedStorage.CameraFolder.MenuCamera.OnServerEvent:Connect(function(player)
	replicatedStorage.CameraFolder.MenuCamera:FireClient(player)
end)

replicatedStorage.CameraFolder.PlayerCamera.OnServerEvent:Connect(function(player)
	replicatedStorage.CameraFolder.PlayerCamera:FireClient(player)
end)

This will do that when you fire the event from client to server, it will automatically fire from server to player, changing his camera.

Thanks for all the things but my friend all ready fix it for me thanks again to all