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.
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.
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 .
You don’t yield, and wait until the PlayerGui instance is loaded.
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.
You used 2 scripts for camera manipulation which also seems very unnecessary to me.
Using a touch event in a camera manipulation script, seems very unnecessary to me.
You don’t seem to even be checking if this “RunCameraManipulation” value.
Horrible variable naming convention, not using GetService to retrieve services. This is more of a convention then an actual issue with your code though.