Main menu camera manipulation help

So I made a main menu gui, with maps. The main menu is using camera manipulation. I made it that when you click on a map you want to go to out of the main menu, the camera manipulation is turned off (btw this is an obstacle course game), the problem is when you die instead of going to a checkpoint, the Camera manipulation turns back on again, and you lose all of your progress on the obstacle course. Any way to only turn on the cam manipulation when you finished completing the course?

local cam = workspace.CurrentCamera

local plr = game.Players.LocalPlayer
local char = plr.Character

script.Parent.MouseButton1Click:Connect(function()
	print("Tp to neon revelation")
	char.HumanoidRootPart.CFrame = workspace.NeonRevelationtp.CFrame
	game.StarterPlayer.StarterCharacterScripts.camera.Disabled = true
	cam.CameraType = "Custom"
end)

Oh, and here is the camera script.

wait()
print("cam has started running.")
local cam = workspace.CurrentCamera
local FocusPart = game.Workspace.MainMenuCam

repeat cam.CameraType = Enum.CameraType.Scriptable until cam.CameraType == Enum.CameraType.Scriptable
cam.CFrame = FocusPart.CFrame
1 Like

you can just add a BoolValue to the character’s player, and use an if statement so that when you want to turn it on, run the camera manipulation script.

if player.RunCameraManipulation.Value == false then return end
--your camera script here

Wait, how would I add a BoolValue to a character’s player?

1 Like

put this in a script in server script service:

game.Players.PlayerAdded:Connect(function(player)
local boolVal = Instance.new("BoolValue")
boolValue.Name = "RunCameraManipulation"
boolVal.Parent = player
end)

and refer to it by calling:

player.RunCameraManipulation = true/false

for documentation: Players | Documentation - Roblox Creator Hub

It would be a regular script, or a local script?

1 Like

Also, how would I get player. since game.Players.PlayerAdded:Connect(function(player)
for some reason still doesn’t get it and under lines player in
player.RunCameramanipulationi = true/false

2 Likes

the script is a Script (not local)

to get the player in script:

game.Players.PlayerAdded:Connect(function(player)
player.stuff = stuff
end)

in local script:

game.Players.LocalPlayer.Stuff = stuff

What is the player.stuff for? I’ve never seen that before.

stuff is meaningless, it’s an example.

I am kind of confused. Is this what you mean?

local player = game.Players.LocalPlayer
if player.RunCameraManipulation.Value == false then return end

wait()
print("cam has started running.")
local cam = workspace.CurrentCamera
local FocusPart = game.Workspace.MainMenuCam

repeat cam.CameraType = Enum.CameraType.Scriptable until cam.CameraType == Enum.CameraType.Scriptable
cam.CFrame = FocusPart.CFrame
1 Like

yep, and don’t forget to make sure that the screen gui’s reset on spawn property is false.

1 Like

Well, uh, my camera manipulation script doesn’t work anymore.

1 Like

you should be manipulating the boolValue, so if you want it to run, change

player.RunCameraManipulation.Value = true

and when you want to disactivate it:

player.RunCameraManipulation.Value = false

you should add:

player.RunCameraManipulation.Value = true 

in the player added event, and then add a wait(2) and disactivating it again from the reference on top ^^^

1 Like

It tells me in output that RunCameraManipulation isn’t a valid member of player.
Since I put this in my gui script, the player was = game.Players.LocalPlayer. Maybe that is making the script not work, but idk.

1 Like

game.Players.LocalPlayer shouldn’t be the issue, can you send the new code?

1 Like

My bad. I was using the code wrong. It works perfectly fine. Ty for going out of your way to help me.

2 Likes

So, in the game there is an obstacle course, and I’m tring to make it that when you reach the end and touch a part it enables the cam and main menu. I set the boolvalue to true, and doesn’t work. Any help?

local Player = game.Players.LocalPlayer
local playergui = Player.PlayerGui
local MainMenu = playergui:WaitForChild("MainMenu")
local MainMenuTouch = script.Parent

MainMenuTouch.Touched:Connect(function()
	MainMenu.Enabled = true
	Player.RunCameraManipulation.Value = true
end)

Here is the script that I had.

when the player reaches the end, kill his character.

Humanoid.Health = 0

But that will only make him go to the last checkpoint.