Giter Club home page Giter Club logo

Comments (10)

Lucke0051 avatar Lucke0051 commented on May 28, 2024

I can't replicate. Here is a place where it works for me.
Wait 5 sec and you will see the topbar go away and then 5 sec after it will come back.
https://drive.google.com/file/d/16v4vmxysWvlYb9KI1Ll3w93C3Iy0mZHF/view?usp=sharing

from core.

Lucke0051 avatar Lucke0051 commented on May 28, 2024

Though maybe placing the guis in replicated storage or something, then letting a script on the client clone it would be good. As that would not require the player to spawn either, and it saves server resources.

from core.

1ForeverHD avatar 1ForeverHD commented on May 28, 2024

This sounds as if the DirectoryService is incorrectly loading Topbar+ due to your particular method, as apposed to there being an issue with the Icon and icon:setTopbarEnabled().

Are you able to provide a repo place file of this bug?

from core.

AlessandroG200 avatar AlessandroG200 commented on May 28, 2024

Small video of the issue in action:
(Had to zip it because otherwise GitHub would not let me upload it as OBS recorded it as a .mkv file)
ReproVideo.zip

Seems to place-specific as a baseplate doesn't give out this issue.

Test button code:

local c = true

script.Parent.MouseButton1Click:Connect(function()
	c = not c
	
	if c then
		script.Parent.Text = "Disable Topbar"
	else
		script.Parent.Text = "Enable Topbar"
	end
	
	local Test = game:GetService("Players").LocalPlayer.PlayerGui:WaitForChild("Topbar+")
	
	if not Test:FindFirstChild("WaitReturn") then -- Make a value on the GUI that is returned by WaitForChild.
		local x = Instance.new("StringValue")
		x.Name = "WaitReturn"
		x.Parent = Test
	end
	
	print("In")
	local BaseHD = game:GetService("ReplicatedStorage"):WaitForChild("HDAdmin"):WaitForChild("Topbar+")
	local Topbar = require(BaseHD:WaitForChild("IconController"))
	
	Topbar:setTopbarEnabled(c)
	print("Out")
end)

from core.

1ForeverHD avatar 1ForeverHD commented on May 28, 2024

Your client icon creator is fine, it's how you're loading Topbar+ which is almost certainly the issue, in particular this:

image

The Topbar+ server (i.e. DirectoryService) automatically handles the cloning of GUIs into a player's PlayerGUI. By cloning this yourself, the Topbar+ GUI is being cloned twice, which is creating all the issues mentioned above.

For an ideal setup:

  1. Topbar+ can be initiated in a Script in ServerScriptService with require(4874365424)
  2. Your icon creator local script should be placed within StarterPlayerScripts

from core.

AlessandroG200 avatar AlessandroG200 commented on May 28, 2024

Ok, reading DirectoryService, the conflict is that DirectoryService initializes the GUI into PlayerGui as you say, however, it waits until a character is spawned. In my loading script, I clone it BEFORE the character spawns, and since DirectoryService runs on the server, it will not see the client copy of the GUI, therefore cloning it again.

Meanwhile, I have a local variable with the GUI, I will have the client hook the PlayerGui and destroy the duplicate.

from core.

1ForeverHD avatar 1ForeverHD commented on May 28, 2024

Due to the way Roblox initialises their player, the 'early-joiners' system within the DirectoryService has to wait until the character has loaded plus one heartbeat before cloning in the Topbar+ GUI.

Can you explain in more detail why you're creating a duplicate in the first place? Can you not simply wait until the original GUI is loaded in and reference that instead?

from core.

AlessandroG200 avatar AlessandroG200 commented on May 28, 2024

I think it is cleaner to load the topbar now rather than on character spawn, so when the character is spawned, everything is already loaded in, also, I have my Backpack, Admin Panel and Main UI modules create the icons as part of the game loading process (not to mention that my Backpack script hooks the B button to the Icon).

from core.

1ForeverHD avatar 1ForeverHD commented on May 28, 2024

Without forking this repository to create your desired effect, there isn't much else that can be done at this point in time. Do consider, Topbar+ only waits for the character for players who join really fast (i.e. maybe the first 1 to 2 players at most). For others, the Topbar+ GUI is added when their player instance is added.

In the future, my plan is to scrap the DirectoryService completely and have projects (such as Topbar+) initialised in studio via a plugin (as apposed to live in-game through a MainModule) to help in situations like yours.

from core.

AlessandroG200 avatar AlessandroG200 commented on May 28, 2024

Meanwhile, I will use the solution to remove the GUI that DirectoryService clones, as far as I tested, removing the duplicate solves the main problem: setTopbarEnabled

About forking the repository, I might make a pull request for this.

Thanks for the information. I will close this issue for now.

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.