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
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.