I have a main menu camera that is supposed to change what the player sees but it doesn’t work.
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Camera = workspace.CurrentCamera
repeat task.wait() until game:IsLoaded()
repeat task.wait()
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = workspace.MainMenu.CameraMenu.CFrame
there are no errors in the output
It is a local script in the startergui and it works in studio, but not client
Player = game.Players.LocalPlayer
Character = Player.Character
Camera = workspace.CurrentCamera
MainMenu = workspace.MainMenu
wait() -- This simple wait is important
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = MainMenu.CameraMenu.CFrame
edit: it works, but whenever I press the play button it doesn’t work
the play button does this:
script.Parent.MouseButton1Click:Connect(function(player)
script.Parent.Parent.Parent:Destroy()
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Custom
game.StarterPack.AudioVisualizer.Enabled = false
game.StarterPack.AudioVisualizer:Destroy()
workspace.MainMenuSong:Stop()
end)
script.Parent.MouseButton1Click:Connect(function(player)
script.Parent.Parent.Parent:Destroy()
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Custom
game.StarterPack.AudioVisualizer.Enabled = false
game.StarterPack.AudioVisualizer:Destroy()
game.StarterGui.Camera:Destroy()
workspace.MainMenuSong:Stop()
local PlayerIsReady = true
local MainMenu = workspace.MainMenu
while wait() and PlayerIsReady == true do
Camera.CameraType = Enum.CameraType.Custom
Camera.CFrame = MainMenu.CameraMenu.CFrame
end
end)
whenever it gets pressed a whole lot of bugs happen, I cant explain them all
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local PlayerIsReady = false
while wait() and PlayerIsReady == false do
Camera.CameraType = Enum.CameraType.Custom
Camera.CFrame = MainMenu.CameraMenu.CFrame
end
Players.PlayerAdded:Connect(function()
PlayerIsReady = true
end)
script.Parent.MouseButton1Click:Connect(function(player)
script.Parent.Parent.Parent:Destroy()
Camera.CameraType = Enum.CameraType.Custom
game.StarterPack.AudioVisualizer.Enabled = false
game.StarterPack.AudioVisualizer:Destroy()
game.StarterGui.Camera:Destroy()
workspace.MainMenuSong:Stop()
local MainMenu = workspace.MainMenu
end)
local MainMenu = workspace.MainMenu
local Camera = workspace.CurrentCamera
local PlayerIsReady = false
co = coroutine.create(function()
while PlayerIsReady == false do
wait()
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = MainMenu.CameraMenu.CFrame
end
end)
if PlayerIsReady == false then
coroutine.resume(co)
else
coroutine.close(co)
end
script.Parent.MouseButton1Click:Connect(function(player)
--script.Parent.Parent.Parent:Destroy()
PlayerIsReady = true
Camera.CameraType = Enum.CameraType.Custom
--game.StarterPack.AudioVisualizer.Enabled = false
--game.StarterPack.AudioVisualizer:Destroy()
--workspace.MainMenuSong:Stop()
script:Destroy()
end)
You’re not checking if the workspace is loaded before running the rest of your script.
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Camera = workspace.CurrentCamera
repeat task.wait() until workspace:IsLoaded()
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = workspace.MainMenu.CameraMenu.CFrame