`PlayerGui` is not valid member of player

i’m making an script which will look for player using string value and then find PlayerGui inside it.
and yes i’ve seen an post similiar to this but its not the right solution

script:

function onYes()
	if game.Players:WaitForChild(script.Parent.Parent.barista.Value):IsA("Player") then
	game.Players:WaitForChild(script.Parent.Parent.barista.Value).PlayerGui.GiveSystem.AddPoint:FireServer(script.Parent.Parent.barista.Value)
--	item.Parent = game.Players.LocalPlayer.Backpack
	script.Parent:TweenPosition(UDim2.new(0.5, -200,0,-121))
	wait(1)
	script.Parent:Destroy()
	end
end
3 Likes

Is this a LocalScript.

If so, is this script located inside the PlayerGui?

1 Like

yes, this is local script and it is inside startergui or you can say playergui.

2 Likes

Either way, you might want to spread out your WaitForChilds like so:

function onYes()
	
	if Players:FindFirstChild(script.Parent.Parent.barista.Value) then
		local Player = Players[script.Parent.Parent.barista.Value]
		local PlayerGui = Player:WaitForChild("PlayerGui")
		local GiveSystem = PlayerGui:WaitForChild("GiveSystem")
		local AddPoint = GiveSystem:WaitForChild("AddPoint")
		
		AddPoint:FireServer() -- Player is sent automatically
		script.Parent:TweenPosition(UDim2.new(0.5, -200,0,-121))
		wait(1)
		script.Parent:Destroy()
	end
end

It may solve your issue.

1 Like

How do you define barista and what Value is it?

1 Like

barista is a stringvalue and it is has name of an player, and i tried printing planet name and it works fine but i have some issues with PlayerGui

1 Like

this script doesn’t work, it doesn’t print any errors now but script just doesn’t work which means that it still has same error.

1 Like

Try adding a warning to let you know what the problem is:

function onYes()
	
	if Players:FindFirstChild(script.Parent.Parent.barista.Value) then
		local Player = Players[script.Parent.Parent.barista.Value]
		local PlayerGui = Player:WaitForChild("PlayerGui")
		local GiveSystem = PlayerGui:WaitForChild("GiveSystem")
		local AddPoint = GiveSystem:WaitForChild("AddPoint")
		
		AddPoint:FireServer() -- Player is sent automatically
		script.Parent:TweenPosition(UDim2.new(0.5, -200,0,-121))
		wait(1)
		script.Parent:Destroy()
	else
		warn(script.Parent.Parent.barista.Value, "was not found in Players")
	end
end
1 Like

it does detect player. as i said earlier i tried printing it before.

1 Like

With the warning added, do you see the warning in the output window?

1 Like

it does not print any error in output window.

1 Like

No errors at all?

Also, make sure the line is:

AddPoint:FireServer() -- Player is sent automatically

1 Like

no, its not the local script player, its player that is found by the value.

1 Like

That makes sense now.

Try:

function onYes()
	
	if Players:FindFirstChild(script.Parent.Parent.barista.Value) then
		local Barista = Players[script.Parent.Parent.barista.Value]
		local PlayerGui = Barista:WaitForChild("PlayerGui")
		local GiveSystem = PlayerGui:WaitForChild("GiveSystem")
		local AddPoint = GiveSystem:WaitForChild("AddPoint")
		
		print("Barista is =", Barista)
		
		AddPoint:FireServer(Barista) -- Client is sent automatically
		script.Parent:TweenPosition(UDim2.new(0.5, -200,0,-121))
		wait(1)
		script.Parent:Destroy()
	else
		warn(script.Parent.Parent.barista.Value, "was not found in Players")
	end
end

it didn’t print anything for some reasons

Then add a print statement immediately after the function name:

function onYes()
	
	print("OnYes Called")
	
	if Players:FindFirstChild(script.Parent.Parent.barista.Value) then
		local Barista = Players[script.Parent.Parent.barista.Value]
		local PlayerGui = Barista:WaitForChild("PlayerGui")
		local GiveSystem = PlayerGui:WaitForChild("GiveSystem")
		local AddPoint = GiveSystem:WaitForChild("AddPoint")
		
		print("Barista is =", Barista)
		
		AddPoint:FireServer(Barista) -- Client is sent automatically
		script.Parent:TweenPosition(UDim2.new(0.5, -200,0,-121))
		wait(1)
		script.Parent:Destroy()
	else
		warn(script.Parent.Parent.barista.Value, "was not found in Players")
	end
end

oh my bad i looked on server output window and not local, here is error: Infinite yield possible on ‘Players.Player1:WaitForChild(“PlayerGui”)’

Not sure if this is your problem but, I think this should be:
if game.Players.script.Parent.Parent:WaitForChild(“barista”).Value then

Do you see this error when you play without using Testing?

The thing is, players can never see the other PlayersGui.

I think I see your issue now.

1 Like