Help with Main Menu

So, I am making a game in which you do obstacle courses in. I have made a main menu with camera manipulation with different buttons that go to different maps. I have already figured out how to disable the camera manipulation when you tp to a map, but I also want to make it that when you press “p” on your keyboard you go back to main menu with camera manipulation and all. The script is in startplayer scripts.

local Player = game.Players.LocalPlayer
local playergui = Player.PlayerGui
local MainMenu = playergui("MainMenu")
local cam = workspace.CurrentCamera

local UIS = game:GetService("UserInputService")
local CHar = Player.Character or Player.CharacterAdded:Wait()
UIS.InputBegan:Connect(function(Input,G)
	if not G and Input.KeyCode == Enum.KeyCode.P then
		print("p pressed")
		MainMenu.Enabled = true
		cam.CameraType = "Custom"
		Player.RunCameraManipulation = true
    end
end)

I am also trying to make it that when you complete a map you go back to main menu with camera manipulation enabled. Here is the script for that.

local Player = game.Players.LocalPlayer
local playergui = Player.PlayerGui
local MainMenu = playergui:WaitForChild("MainMenu")
local MainMenuTouch = script.Parent
local cam = workspace.CurrentCamera
MainMenuTouch.Touched:Connect(function()
	MainMenu.Enabled = true
	Player.RunCameraManipulation.Value = true
	cam.CameraType = "Custom"
end)

It turns on the main menu, but doesn’t turn on the camera manipulation.

3 Likes

I guess you have to set the CameraSubject.
Or you got this wrong in the first script snippet.

Player.RunCameraManipulation = true

But in the second you use this.

Player.RunCameraManipulation.Value = true

Maybe this is the problem in your script.

Hmmm, still doesn’t work. :man_shrugging:

1 Like

Change the first one to use .Value

i did, and in the second script when i press “p” nothing prints out like its suppose to.

1 Like

For your first issue, I actually made a tutorial on Keybinds a while ago, and I think that it’s relevant in your situation… https://youtu.be/Et7VSfyEj4E

As for the camera not going into custom, this happens to me all the time. Here’s some code that will help…

repeat 
cam.Canercam.CameraType = Enum.CameraType.Custom
wait()
until cam.Canercam.CameraType == Enum.CameraType.Custom

If this helped you, feel free to mark this as solution.

Ok, will be trying this out, sorry for late response.

2 Likes

Did this work for you?

Oh, sorry didn’t try it out yet. I had to go to bed.

2 Likes

Hello, sorry for the late response I have just been busy lately, but your video was amazing, and did work. Partly. Here is my script.

local input = game:GetService("UserInputService")

input.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.P then
		player.RunCameraManipulation.Value = true
		MainMenu.Enabled = true
	end
end)

So the runcameramanipulation is a bool value, that when set to true will enable the camera manipulation, but it doesn’t work for some reason. Help is appreciated .

1 Like

No no no no no no no no no no.

Don’t use a loop to change properties, that a horrible coding practice.

Well, do you think you can help with my script? <3

There’s quite a few issues with your script.

  1. You don’t yield, and wait until the PlayerGui instance is loaded.
  2. I assume you tried accessing a value in the player to tell some other code to run some camera manipulation, this is completely unnecessary in my opinion.
  3. You used 2 scripts for camera manipulation which also seems very unnecessary to me.
  4. Using a touch event in a camera manipulation script, seems very unnecessary to me.
  5. You don’t seem to even be checking if this “RunCameraManipulation” value.
  6. Horrible variable naming convention, not using GetService to retrieve services. This is more of a convention then an actual issue with your code though.

Well, I need to enable the main menu and camera manipulation once someone finishes the obstacle course. So touched event. ;~;.