Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Infinite yield possible on 'Players.Player1.PlayerGui:WaitForChild("Backpack Gui")'?

I'm trying to do a script that removes the Gui "Backpack Gui" from all players after 5 seconds, i know, the infinite yield its not an ERROR, but it seems to never found!

Here's the script [It's just a resume of what I'm really trying to do]

for _,player in pairs(game:GetService("Players"):GetPlayers()) do

local BPGui = player.PlayerGui:WaitForChild("Backpack Gui")

wait(0.1)

BPGui:Destroy()
end

3 comments

0

Well, is the backpack gui ever made?

0

If that's the only error code that shows in the output, it's just a warning, and if you're bothered by it then add a time argument in the WaitForChild(). If there's more error code then post it, that will show us if "Backpack Gui" even exists.

0

I assume this is in a server script which means it won't work because you can't acces PlayerGui from server

1 answer

✓ Accepted answer

Only the client (player) can access the gui. If you want the server to be able to access the GUI, clone it and set it's parent to the player's PlayerGui.

Server script:

--store the backpack gui in serverstorage or wherever you want
local BackpackGUI = game.ServerStorage["Backpack Gui"]

game.Players.PlayerAdded:Connect(function(newPlayer)
	newPlayer.CharacterAdded:Connect(function(character)
		local guiClone = BackpackGUI:Clone()
		guiClone.Parent = newPlayer.PlayerGui
	end)
end)

1 comment

0

Thank You So Much <3

This discussion is preserved as it was. New answers, comments, and votes are closed.