I have a character selection GUI that shows up whenever the player dies. While in that menu, I want the players camera to be locked to an invisible part that is spinning around in the world, kind of like Minecraft’s panorama effect. When playtesting in Studio, everything works fine, but when playing on a local server or a real server, it doesn’t work, except for when the player joins the game. I accomplish this by using this script:
while true do
wait(0.1)
if script.Parent.Enabled == true then
print("Panorama Enabled")
--Camera
local Camera = game.workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = game.Workspace.camera.CFrame
--Gui
script.Parent.Parent.Meny.Enabled = false
script.Parent.Parent.Markers.Enabled = false
script.Parent.Parent.HungerAndHealthBar.Enabled = false
script.Parent.Parent.Message.Enabled = false
script.Parent.Parent.Markers.Castle.Enabled = false
script.Parent.Parent.Markers.Dungeon.Enabled = false
script.Parent.Parent.Markers.Pyramid.Enabled = false
script.Parent.Parent.Markers.Mountain.Enabled = false
else
--Camera
local Camera = game.workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Follow
--Gui
script.Parent.Parent.Meny.Enabled = true
script.Parent.Parent.Markers.Enabled = true
script.Parent.Parent.HungerAndHealthBar.Enabled = true
script.Parent.Parent.Message.Enabled = true
end
end
Does anyone know how to fix this? Help greatly appreciated
At first, your code really need to be optimized !
Also, i’m wondering what you are referencing there:
Camera.CFrame = game.Workspace.camera.CFrame
Is it a part or something ? because, there is already a camera object in workspace so you can’t name parts with this name, and there is no point to put camera CFrame to the camera CFrame.
I can’t really help if you don’t show your camera animation code so i can know how your system work overall.
local Camera = workspace.CurrentCamera
local Toggle = script.Parent
local function PanoramaDisabled()
Camera.CameraType = Enum.CameraType.Follow
script.Parent.Parent.Meny.Enabled = true
script.Parent.Parent.Markers.Enabled = true
script.Parent.Parent.HungerAndHealthBar.Enabled = true
script.Parent.Parent.Message.Enabled = true
end
local function PanoramaEnabled()
Camera.CameraType = Enum.CameraType.Scriptable
script.Parent.Parent.Meny.Enabled = false
script.Parent.Parent.Markers.Enabled = false
script.Parent.Parent.HungerAndHealthBar.Enabled = false
script.Parent.Parent.Message.Enabled = false
script.Parent.Parent.Markers.Castle.Enabled = false
script.Parent.Parent.Markers.Dungeon.Enabled = false
script.Parent.Parent.Markers.Pyramid.Enabled = false
script.Parent.Parent.Markers.Mountain.Enabled = false
coroutine.resume(coroutine.create(function()
repeat task.wait(0.1)
Camera.CFrame = workspace.camera.CFrame
until
Toggle.Enabled == false
end))
end
Toggle.Changed:Connect(function()
if Toggle.Enabled == true then
PanoramaEnabled()
else
PanoramaDisabled()
end
end)