How to make touch brick for main menu

So I am making an obstacle course game with my friends, and I want to make it that when someone finishes the obstacle course and touches something the main menu will be enabled, and the camera manipulation that goes along with the main menu also enabled. I put the camera manipulation into a bool value, player.RunCameraManipulaiton.Value = true, it works for other things, but for some reason not with the script I originally made. Which I forgot since I deleted it.

3 Likes

If touching the button is only meant to affect your UI and Camera, you don’t need to listen to a Changed event on a boolvalue. Just rig up the Touched event from the client.

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

function CameraEdit()
-- Code
end

function ShowMenu()
-- Code
end

Humanoid.Touched:Connect(function(part)
     if part.Name == "GoalPart" then -- Feel free to change this
          CameraEdit(); ShowMenu()
     end
end)
3 Likes

How would I edit the camera inside of CameraEdit().

There’s a neat little wiki tutorial here.

Set up a subroutine within the function, then start a loop. Just make sure the loop has an end condition for when the character dies/respawns.

1 Like

Well, I want it that when they finish they will just go back to main menu to pick another obstacle or something. Would I put the script into local script? I’lll take a look at the wiki. I have a camera script in a different script, and I just want to activate it, but the wiki that you sent doesn’t seem to explain that.

This would be a localscript, yes.

You can set up your GUI to teleport people where they need to go. Should be self-explanatory from there. You might consider a BindableEvent to tell the menu when to open or close.

I only need help with activating the camera manipulation. I’ve already set it up to tp people where they need to go, I just need to finish up the end of the obstacle course.

local Player = game.Players.LocalPlayer
local playergui = Player.PlayerGui
local MainMenu = playergui:WaitForChild("MainMenu")
local MainMenuTouch = script.Parent
local cam = workspace.CurrentCamera
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

function CameraEdit()
	Player.RunCameraManipulation.Value = true
	repeat cam.CameraType = Enum.CameraType.Scriptable until cam.CameraType == Enum.CameraType.Scriptable
end

function ShowMenu()
	print("Activate main menu")
	MainMenu.Enabled = true
end

Humanoid.Touched:Connect(function(part)
	if part.Name == "GoalPart" then -- Feel free to change this
		CameraEdit(); ShowMenu()
	end
end)

This is the script I made, Idk if I did this correct or not. When I touch it it doesn’t print out (“Activate Main Menu”) like its suppose to.

I would instead add a script into the part itself and add script.Parent.Touched:connect(function (hit)
If hit.Parent:FindFirstChild(“Humanoid”) then
local player = hit.Parent
player.PlayerGui.MainMenu.Visible = true
end)

1 Like

Well, how would I get to activate the camera manipulation also?

inside the script you can add
Local cam = game.Workspace.CurrentCamera
and when the brick is touched, you can make it scriptable. After you should be able to change the properties of the camera.