I am attempting to destroy a GUI once you click a TextButton. I've tried this many ways, some of which worked in Play Solo in Roblox Studio but that do not work in the actual game. My most recent attempt was using a script in Workspace that cycled through all the player's backpacks to look for a script in the player's backpack that had a remove event. However, I'm new to filtering enabled and I don't understand why it doesn't work.
Normal Script in Workspace
for i,v in pairs(game.Players:GetPlayers()) do
if v:FindFirstChild("Backpack")then
v.Backpack.CloseGUI.CloseGUIs:FireClient()
end
end
Local Script in Starterpack that is the parent to the RemoveEvent
script:WaitForChild("CloseGUIs")
script.Parent.Parent.PlayerGui.Shop.timema.Close.MouseButton1Click:connect(function()
script.CloseGUIs.OnClientEvent:connect(function()
script.Parent.Parent.PlayerGui.Shop:Destroy()
end)
end)

2 comments
I'm a bit confused. I put both of your new scripts, client and server both into lighting. I'm not sure if I was supposed to do that but I'm assuming I wasn't because the GUI isn't being deleted.
Ah, I forgot something. It's fixed now. If you have more problems, hmu on ROBLOX.