Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[=================================================
- SH QUESTION: Wondering how to use UserInputService to make "M = Go back to MenuGui" ?
- > DATE: 1/13/2022
- > BY USER: isir2204
- SOLUTION VERSION: 1
- REASON WHY THE ANSWER ON SH WASN'T EDITED:
- > << Visiting scriptinghelpers.org doesn't work (Error 524, connection timeout)
- --]]--START YOUR SELECTION ON THE NEXT LINE---------
- -- Variables
- local player = game.Players.LocalPlayer
- local character = player.CharacterAdded
- local UIS = game:GetService("UserInputService")
- local mouse = player:GetMouse()
- local camera = game.Workspace.Camera
- local defualtCFrame = camera.CFrame
- local view = 150
- local blur = game.Lighting.Blur
- local menuMusic = game.Workspace.MenuMusic
- local menuFrame = script.Parent.MenuFrame
- local menuOn = false
- -- Scripting in Action
- local connection
- function updateCamera()
- camera.CFrame = game.Workspace.MenuCamPart.CFrame
- end
- function showMenu() -- Moved most of the code from onInputBegan to here.
- menuOn = true
- wait(0.2)
- blur.Size = 11
- menuMusic:Play()
- camera.CameraType = Enum.CameraType.Scriptable -- You might need this to be set to scriptable so you can change the CFrame property of the camera.
- menuFrame.Visible = true
- -- Set camera connection
- connection = game:GetService("RunService").RenderStepped:Connect(updateCamera)
- end
- function hideMenu() -- Moved most of the code from "Pressing M" to here.
- menuOn = false
- wait(0.2)
- blur.Size = 0
- menuMusic:Stop()
- camera.CameraType = Enum.CameraType.Custom
- menuFrame.Visible = false
- -- Disconnect camera
- connection:Disconnect()
- end
- -- When the player joins, (or even resets,) automatically show the menu and play the scenery.
- showMenu()
- local function onInputBegan(input : InputObject, gameProcessed)
- if (input.KeyCode == Enum.KeyCode.M) and not menuOn then
- showMenu() -- Executes the function to show menu.
- end
- end
- script.Parent.MenuFrame.DeployButton.MouseButton1Click:Connect(function()
- hideMenu()
- end)
- UIS.InputBegan:Connect(onInputBegan)
Advertisement
Add Comment
Please, Sign In to add comment