i did make a local script so when you click credits button then credits menu appear but it doesnt work
local CreditsGui = game.StarterGui.Menu.Credits
local CreditsMenu = game.StarterGui.CreditsMenu
local Menu = game.StarterGui.Menu
local Player = game.Players.LocalPlayer
--Make that if you click CreditsGui then Menu is gonna disappear and CreditsMenu is gonna appear
CreditsGui.MouseButton1Click:Connect(function()
Menu.Enabled = false
CreditsMenu.Enabled = true
end)
This is your issue. When you are referencing a UI in the LocalPlayer, you need to use PlayerGui, instead of StarterGui. StarterGui is just a place where you put all the UIs and frames and whatnot that will be cloned to each players’ PlayerGui. Therefore, try changing your script to the following:
local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local Menu = PlayerGui.Menu
local CreditsGui = Menu.Credits
local CreditsMenu = PlayerGui.CreditsMenu
--Make that if you click CreditsGui then Menu is gonna disappear and CreditsMenu is gonna appear
CreditsGui.MouseButton1Click:Connect(function()
Menu.Enabled = false
CreditsMenu.Enabled = true
end)
Are you sure you’re getting that error from the same script? From what I can see, that’s an error from a ServerScript you have in your game that is different from the LocalScript you’re using
Are you sure the UI is directly under the PlayerGui?
We can try using WaitForChild in case it didn’t load in properly.
local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local Menu = PlayerGui:WaitForChild("Menu")
local CreditsMenu = PlayerGui:WaitForChild("CreditsMenu")
local CreditsGui = Menu.Credits
--Make that if you click CreditsGui then Menu is gonna disappear and CreditsMenu is gonna appear
CreditsGui.MouseButton1Click:Connect(function()
Menu.Enabled = false
CreditsMenu.Enabled = true
end)