--Module script:
local UIController = {}
function UIController.SwitchTo(To)
for _,v in pairs(game.StarterGui:GetChildren()) do
if v.Name ~= 'TopBar' or v.Name ~= 'Chat' then
if v:IsA("ScreenGui") then
v.Enabled = false
if v.Name == To then
v.Enabled = true
end
end
end
end
end
return UIController
--Local Script:
local UIController = require(game.StarterGui.UIController)
script.Parent.MouseButton1Click:Connect(function()
UIController.SwitchTo('HomePage')
end)
-- Module script:
local UIController = {}
function UIController.SwitchTo(To)
for _,v in pairs(game.Players.LocalPlayer.PlayerGui:GetChildren()) do
if v.Name ~= 'TopBar' or v.Name ~= 'Chat' then
if v:IsA("ScreenGui") then
v.Enabled = false
if v.Name == To then
v.Enabled = true
end
end
end
end
end
return UIController
--Local Script:
local UIController = require(game.StarterGui.UIController)
script.Parent.MouseButton1Click:Connect(function()
UIController.SwitchTo('HomePage')
end)
Try this one.
You’re trying to edit player’s gui with accessing StarterGui. Nothing in StarterGui is in the player’s screen. StarterGui only cloning Gui into player’s gui.
-- Module script:
local UIController = {}
local playerGui = game.Players.LocalPlayer.PlayerGui
function UIController.SwitchTo(To)
for _,v in pairs(playerGui:GetChildren()) do
if v.Name ~= 'TopBar' or v.Name ~= 'Chat' then
if v:IsA("ScreenGui") then
v.Enabled = false
end
end
end
playerGui[To].Enabled = true
end
return UIController
--Local Script:
local UIController = require(game.Players.LocalPlayer.UIController)
script.Parent.MouseButton1Click:Connect(function()
UIController.SwitchTo('HomePage')
end)
-- Module script:
local UIController = {}
local playerGui = game.Players.LocalPlayer.PlayerGui
function UIController.SwitchTo(To)
for _,v in pairs(playerGui:GetChildren()) do
if v.Name ~= 'TopBar' or v.Name ~= 'Chat' then
if v:IsA("ScreenGui") then
v.Enabled = false
end
end
end
playerGui[To].Enabled = true
playerGui['TopBar'].Enabled = true
end
return UIController
--Local Script:
local UIController = require(game.Players.LocalPlayer.UIController)
script.Parent.MouseButton1Click:Connect(function()
UIController.SwitchTo('HomePage')
end)