Main Menu Script not Working

I am trying to make a main menu script for my game. However, when I click play, nothing happens. There are no errors in the output.

LocalScript:

local Cam = workspace.CurrentCamera
local Menu = script.Parent.Parent
local Buttons = script.Parent.Parent.Parent.ButtonFrame
local Button = Buttons.Parent.TextButton

game.Players.PlayerAdded:Connect(function(Player)
	Cam.CameraType = Enum.CameraType.Fixed
	Menu.Visible = true
	Buttons.Visible = false
	Button.Visible = false
	game.Lighting.MenuBlur.Enabled = true
	local Char = Player.Character or Player.CharacterAdded:Wait()
	Human = Char:WaitForChild("Humanoid")
	Human.WalkSpeed = 0
end)

script.Parent.MouseButton1Click:Connect(function()
	Cam.CameraType = Enum.CameraType.Custom
	Menu.Visible = false
	Buttons.Visible = true
	Button.Visible = true
	game.Lighting.MenuBlur.Enabled = false
	Human.WalkSpeed = 14
end)

I can’t figure out why it’s not working.

(Getting this out of the way but) Is this a script or Local Script?

I forgot to mention, but it is a LocalScript.

What error is comming in the output?

I said that there were no errors.

Then there shouldn’t be anything wrong?

Oh I readed it wrong. My fault :laughing:
Then I don’t know whats wrong.

That’s the problem, there shouldn’t be anything wrong, but there is.

Hm, my guess is that it could be the PlayerAdded event

Could you try removing that & try this instead?

local Cam = workspace.CurrentCamera
local Menu = script.Parent.Parent
local Buttons = script.Parent.Parent.Parent.ButtonFrame
local Button = Buttons.Parent.TextButton
local Player = game.Players.LocalPlayer

Cam.CameraType = Enum.CameraType.Fixed
Menu.Visible = true
Buttons.Visible = false
Button.Visible = false
game.Lighting.MenuBlur.Enabled = true
local Char = Player.Character or Player.CharacterAdded:Wait()
local Human = Char:WaitForChild("Humanoid")
Human.WalkSpeed = 0

script.Parent.MouseButton1Click:Connect(function()
	Cam.CameraType = Enum.CameraType.Custom
	Menu.Visible = false
	Buttons.Visible = true
	Button.Visible = true
	game.Lighting.MenuBlur.Enabled = false
	Human.WalkSpeed = 14
end)
1 Like

Where’d you place the script? It might not be working because of its location.

Why use PlayerAdded in a local script? Local scripts already run when the player joins

Where do you define Human?

I have it in the StarterGui, so it shows the menu every time the player dies. This is why I used PlayerAdded.

Disable the ResetOnSpawn property where your ScreenGui object is

Okay, it works now! Thank you!

1 Like