GUI: Attempt to index nil with PlayerGui

To mention in this case there are 2 persons involved, the “staff” and the “customer”, the customer is signaled by a textbox and the staff is the local plr.

In this case, I have 2 scripts one local and a normal script, in this case the error is with the normal script which activates the process with a RemoteFunction. I already tried to add a value to PlayerGui with:

local PlayerGui = Target:FindFirstChild("PlayerGui")
local PlayerGui = Target:WaitForChild("PlayerGui")

But nothing happens here is the full script (as told before it’s activated by a RemoteFunction but in this case the PlayerGui error is handled by a click)
Here’s the script:

local RPS = game:GetService("ReplicatedStorage")
local MCI = RPS.MCI
local Name = MCI.Classes
local ID = MCI.IDS
local Tickets = MCI.Tickets
local MPS = game:GetService("MarketplaceService")
local class1ticket = Tickets.Class1.Value
local class1active = true
local class2active = true
local class3active = true
local class4active = true
local ID1 = ID.Class2.Value
local ID2 = ID.Class3.Value
local ID3 = ID.Class4.Value
local class2 = false
local class3 = false
local class4 = false
local Text = script.Parent.Parent.System.Player.Text
local Target = game:GetService("Players"):FindFirstChild(Text) 

MCI.Handler.OnServerInvoke = function(plr, command)
	script.Parent.Parent.StaffPromptHandler:TweenPosition(UDim2.new(0.29, 0,0.014, 0))
	wait(1)
	script.Parent.Parent.StaffPromptHandler.Purchase.Text = "Please wait ."
	script.Parent.Parent.StaffPromptHandler.Upgrade.Text = "Please Wait ."
	wait(.1)
	script.Parent.Parent.StaffPromptHandler.Purchase.Text = "Please wait .."
	script.Parent.Parent.StaffPromptHandler.Upgrade.Text = "Please Wait .."
	wait(.1)
	script.Parent.Parent.StaffPromptHandler.Purchase.Text = "Please wait ..."
	script.Parent.Parent.StaffPromptHandler.Upgrade.Text = "Please Wait ..."
	wait(.1)
	script.Parent.Parent.StaffPromptHandler.Purchase.Text = "Please wait ..."
	script.Parent.Parent.StaffPromptHandler.Upgrade.Text = "Please Wait ..."
	wait(.1)
	script.Parent.Parent.StaffPromptHandler.Purchase.Text = "Please wait .."
	script.Parent.Parent.StaffPromptHandler.Upgrade.Text = "Please Wait .."
	wait(.1)
	script.Parent.Parent.StaffPromptHandler.Purchase.Text = "Please wait ."
	script.Parent.Parent.StaffPromptHandler.Upgrade.Text = "Please Wait ."
	wait(.1)
	script.Parent.Parent.StaffPromptHandler.Purchase.Text = "PromptPurchase"
	script.Parent.Parent.StaffPromptHandler.Upgrade.Text = "Upgrade"
end
script.Parent.Parent.StaffPromptHandler.Purchase.MouseButton1Click:Connect(function()
	script.Parent.Parent.StaffPromptHandler:TweenPosition(UDim2.new(0.29, 0,-1.014, 0))
	wait(.5)
	Target.PlayerGui.MCI.CustomerPromptHandler:TweenPosition(UDim2.new(.29, 0,0.014, 0))
end)
1 Like

Used events to connect with a local script.