For some reason everything else is telling me this is fine yet visually its wrong. (UI PROBLEM)

So I am using a module script on a GUI part so I can call functions from other scripts so I don’t have to keep repeating the same code In other local scripts, although for some reason the GUI frame isn’t popping up even though everything else in the module script function is running fine.

Here is a video of me first reviewing my code, and then showing what happens:

Now here is my code in the referenced module script:

local SwitcherDisabler = {}

local StarterGUI = game:GetService("StarterGui")
local SwitcherDisabledGui = script.Parent

function SwitcherDisabler.DisableSwitcher()
	StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
	SwitcherDisabledGui.Visible = true
end

function SwitcherDisabler.EnableSwitcher()
	StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,true)
	SwitcherDisabledGui.Visible = false
end

return SwitcherDisabler

And here is the Code in the referenced local script (other stuff happens in the server script, you can ignore that):

local SwitcherDisabler = require(game.StarterGui.GUI.SwitcherDisableGUI.SwitcherDisableScript)
local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:FindFirstChild("Humanoid")
local animation = tool.divineBlastAnimation
local animationTrack = humanoid.Animator:LoadAnimation(animation)
local RemoteEvent = tool.divineBlastEvent
local debounce = false

tool.Activated:Connect(function()
	animationTrack:Play()
	SwitcherDisabler.DisableSwitcher()
	RemoteEvent:FireServer()
end)

RemoteEvent.OnClientEvent:Connect(function()
	SwitcherDisabler.EnableSwitcher()
end)

Now whats supposed to happen is that upon use it hides the backpack rendering it unusable, and the “SWITCHER DISABLED” ui is supposed to appear, but only the backpack disappears. I have looked in the ui and roblox studio renders it visible, and also if I try to uncheck and check the visible box nothing changes.

So I am pretty clueless to what could be happening here, and I know its not the module script being run on the server because its dependent on what called it + the StarterGUI backpack ui being disabled is a local thing but that still worked so I’m pretty clueless.

Any help or tips are greatly appreciated.

try printing the SwitcherDisabledGui in both of the functions, see if it returns the right element.

It doesn’t seem to print anything, and I even tried to put the print before the rest of the code in the function. The coregui being disabled still goes through somehow. (both functions)

So no name? no instance? nothing?

It might be that it can’t find the frame, maybe try something like this:

local SwitcherDisabler = {}

local StarterGUI = game:GetService("StarterGui")
local SwitcherDisabledGui = script.Parent

function SwitcherDisabler.DisableSwitcher()
	if SwitcherDisabledGui and SwitcherDisabledGui:IsA("Frame") then
	StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
		SwitcherDisabledGui.Visible = true
	else
		warn("Could not find frame or instance is wrong type, happened in DisableSwitcher.")
		end
end

function SwitcherDisabler.EnableSwitcher()
	if SwitcherDisabledGui and SwitcherDisabledGui:IsA("Frame") then
	StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,true)
		SwitcherDisabledGui.Visible = false
	else
		warn("Could not find frame or instance is wrong type, happened in EnableSwitcher.")
		end
end

return SwitcherDisabler

what’s scary is that the warn didn’t print.
Edit: the coregui still hid. It seems the it found the frame but still didn’t show it. (so the else didn’t happen)

Instances in StarterGui are copied to Player’s PlayerGui.
In your local script of tool, the module SwitcherDisabler is not the module in your PlayerGui but in the StarterGui.

The first line of the tool script should be like this.

local Player = game:GetService("Players").LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local SwitcherDisabler = require(PlayerGui.GUI.SwitcherDisableGUI.SwitcherDisableScript)
2 Likes

Sorry the tool script? Do you mean the module script or the local script?

Its the local script.

charlimit

1 Like

That seemed to work, I changed my code to this:

local tool = script.Parent
local player = game.Players.LocalPlayer
local SwitcherDisabler = require(player.PlayerGui.GUI.SwitcherDisableGUI.SwitcherDisableScript)
local character = player.Character
local humanoid = character:FindFirstChild("Humanoid")
local animation = tool.divineBlastAnimation
local animationTrack = humanoid.Animator:LoadAnimation(animation)
local RemoteEvent = tool.divineBlastEvent
local debounce = false

tool.Activated:Connect(function()
	animationTrack:Play()
	SwitcherDisabler.DisableSwitcher()
	RemoteEvent:FireServer()
end)

RemoteEvent.OnClientEvent:Connect(function()
	SwitcherDisabler.EnableSwitcher()
end)

Thanks!
Quick question could you either explain the diff between playergui and just the gui or link me something? I thought the GUI was automatically just a local thing.

Basically, everything that’s in starterGui gets replicated/copied into playerGui when you join.

PlayerGui is inside the player itself, while the StarterGui is a service that copies everything into PlayerGui.

Thats basically it.

Read More about it here ig:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.