How to access playerGui in Module script

I get an error whenever I attempt to interact with the PlayerGui through a Module Script

	local plr = game:GetService("Players").LocalPlayer
	local plrGUI =plr.PlayerGui
	local NotificationUI = plrGUI:FindFirstChild("BasicHud"):FindFirstChild("Notif")

if anybody has a solution to this I would be very grateful if you could share it with me

The error indicates that you’re trying to access the local player from the server. You can’t do that

When you’re creating scripts on the Server (e.g. ServerScriptService, ServerStorage, etc.), you cannot access the local player because it simply does not exist. The Server takes care of all the players, not just one, thus creating an error when you try to access the LocalPlayer. On the client (e.g. ReplicatedStorage, StarterPlayer, etc.), this script would work since the local player is the player

However, if you’re trying to access someone’s UI from the server (not recommended), you could do something like this

local Players = game:GetService("Players")
local PlayerChosen = Players:FindFirstChild("Player1")

if PlayerChosen then
    local PlayerGui = PlayerChosen.PlayerGui
    local NotificationUI = PlayerGui:FindFirstChild("BasicHud"):FindFirstChild("Notif")

    -- do whatever you need to do with the UI
end

Don’t forget to mark this post as a solution if this helped :slightly_smiling_face:

I would reccommend using a localscript. It’s never a good idea to try modifying/accessing something on the client side (localplayer,playerGUI,etc.) from the server.