Help getting PlayerGUI

local Player = game.Players:FindFirstChild(script.Parent.Parent.Parent.Name)
while wait(0.1) do
print(Player.PlayerGui.Menus.Premium.Main.ScrollingFrame.YourULTRA.RGB.OnQ.Value)
end

How do i get the UI on the client?
When the ‘OnQ’ value is changed on the client this still prints true

1 Like

You can shorten the script by using Players.LocalPlayer, it’s also best practice to define your services instead of directly indexing them from game. Calling them using the :GetService() method also ensures that the service is started before use.

Please also ensure that you are using a local script because the server will not see any changes made by the client.

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer

local PlayerGui = LocalPlayer.PlayerGui or LocalPlayer:WaitForChild("PlayerGui")
-- Continue defining variables for UI, etc.
1 Like

Does this work on a Server script?

1 Like

Player UI should generally only be ran and edited by local scripts. The .LocalPlayer property can only be used on the client.

This is a server script trying to check the client ui though, so how would i make it work?

If the OnQ value is changed on client it doesn’t get replicated to server. If it’s printing the value without erroring then the problem is within setting the value, not accessing it.

You could try to use a function to get the player, depending on what function you want to use

If you want a server-sided check on a client’s user interface, you’ll need to use a RemoteFunction to send a request from the server, make the client receive and process the request, and then send back the requested information to the server.