Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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
0
Well, is the backpack gui ever made? thebayou 441 — 5y
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. Pojoto 329 — 5y
0
I assume this is in a server script which means it won't work because you can't acces PlayerGui from server Axdrei 107 — 5y

1 answer

Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
5 years ago

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)
0
Thank You So Much <3 zMadZeus 6 — 5y
Ad

Answer this question