I’m trying to make a game with no UI, so everything has to be either SurfaceGuis or other in-game things.
The SurfaceGui is:
Changed at the start of the game (to the viewmodel)
On a mid-small part
The button has the highest Zindex of every Gui object
Nothing else in the way is set to active or interactable
First loading into the game, it does this:
Then, to make the button work, I have to disable and enable AlwaysOnTop on the SurfaceGui. Sometimes it still doesn’t work and it has to wait or something:
I’ve looked into a couple of posts but none seemed to have the same issue I had.
Sweet. Probably needed to load up where it was. I really didn’t think my script as is would work..
Test speculating.. always have to test that stuff till you got it.. should have been close.
well, it still doesn’t work as intended since it needs to wait for some time each time the game loads. Do you have any other solutions for that? Like maybe forcibly load the Gui using a script
Add a localscript to ReplicatedFirst, then place the GUI as a child of that script, instead of anywhere in StarterGUI. Then write
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")
local ClonedGUI = script:WaitForChild("whatever your GUI is called"):Clone()
ClonedGUI.Parent = PlayerGui
Sorry to hear that, I guess it’s not a loading time issue. Have you connected any functions to the button? If not try to connect it to a simple print to figure out if this bug is purely visual or the actual click isn’t working. This of course won’t solve anything but will at least guide us in the right direction.
I have a function connected to the button that prints a message when the mouse enters, and it only works when the button is darkened when hovering (or when it’s loaded)
Pretty stumped tbh, but I’ve read around and found a few cases of Zindex being set to -1 by default causing AlwaysOnTop to not work. Make sure that by changing any properties of the GUI you aren’t somehow resetting the Zindex to -1. Simplest way to check this is to find your button in your PlayerGUI in explorer while testing and replicate the bug while keeping track of the AlwaysOnTop and Zindex values.
Yea this is very strange. Could you try to recreate this bug in as simple a roblox studio file as possible? I could try to mess around with it tomorrow and find a solution.
In the meantime you could try manually setting the Z-index in the script just before/after turning on alwaysontop, as well as triple checking that no other surfaceguis could be overlapping your given one (if you have not already done these).
The screen, when the game starts, is on a part, and with a local script I change it to be on the viewmodel’s screen
I tried to change the size and the CFrame of the part with the initial screen every render step to the viewmodel’s screen using a localscript, and I was able to interact with the stuff in the SurfaceGui.
Although, using this method of changing the screen’s CFrame, the screen has a delay when moving in the 3D space.
I then used this quick local script to weld them together
Maybe keep the WorkspaceScreen anchored and positioned via CFrame updates, not welded into the assembly. SurfaceGuis get input properly if the host part is anchored in world space.
Again test scripting.
local ws = workspace
local vm = ws:WaitForChild("ViewmodelScreen")
local scr = ws:WaitForChild("WorkspaceScreen")
local rs = game:GetService("RunService")
scr.Anchored = true
rs.RenderStepped:Connect(function()
scr.CFrame = vm.CFrame
scr.Size = vm.Size
end)
My gut instinct is you have the SurfaceGui parented to the part that its displaying on, instead of being parented to your PlayerGui and changing the SurfaceGui.Adornee property. Would cause exactly these issues with this pattern of everything or nothing working.
I think I’ll do that, it’s sad that I need to do a band-aid solution like this but I see no other alternatives. Thanks for the help, I’ll mark you as the solution.