Issue with changing the properties of a ScreenGui under the PlayerGui

This is probably a simple fix although for some reason this script is no changing the properties of a ScreenGui that is located in the PlayerGui, of course it is placed in the PlayerGui when the player loads in from StarterGui:

local Player = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')

if script.Disabled == false then

	Player.Begin_Match_Countdown.Enabled = true
	Player.Begin_Match_Countdown.Integer_Txt.Config.Disabled = false
	wait(6)
	
	script.Disabled = true
	
end

The two instances it is trying to change is a script and the main ScreenGui itself (Making it Visible) although nothing changes. I also get no output errors so I’m completely stuck on what to do from here if any one could help that would be great.

So first, is this a localscript or script?

It needs to be a localscript to change client objects/values.

1 Like

It is a Local Script I realised this when I first coded it in a script, although it still does not work.

Try this and let me know what prints/doesn’t. To check which sections of the code may not be working.

print("Print1 Worked!")
local Player = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')
print("Print2Worked!")

if script.Disabled == false then

	Player.Begin_Match_Countdown.Enabled = true
	Player.Begin_Match_Countdown.Integer_Txt.Config.Disabled = false
    print("Print3 Worked!")
	wait(6)
	
	script.Disabled = true
	
end
1 Like

I’m not getting anything through Output. Just a question in case it can all be resolved by this; can the local script be located in the Workspace? Or does it have to be a descendent of another Service?

Ah that’s the problem.

A localscript can only run somewhere in:

  1. StarterGui
  2. A Player’s Character
  3. A Player’s Backpack

I typically put my localscripts for players in StarterPlayerScripts, or StarterGui.

EDIT: There’s a couple other places, like ReplicatedFirst.

Take a look: LocalScript | Documentation - Roblox Creator Hub

1 Like

Okay, so I moved the Local Script into Replicated First and altered the code so it gets enabled when it needs to be although I am still not getting any sort of UI on my screen, do you have a Service in particular that the script should be placed under if it is getting enabled at a later point in the game? I did not use StarterGui because I know it will be replicated into the Player Gui, I will try it now.

Ah wait, If I place it into StarterGui and it replicates into the PlayerGui can I not use the following code?

if script.Disabled == false then

	script.Parent.Begin_Match_Countdown.Enabled = true
	script.Parent.Begin_Match_Countdown.Integer_Txt.Config.Disabled = false
	wait(6)
	
	script.Disabled = true
	
end

Try putting it in StarterGui. It shouldn’t matter if it replicates into the PlayerGui.

Or the alternative would be StarterPlayerScripts.

And make sure you try the prints to check if it’s working.

2 Likes

I think it’s because your script will never run if that screen GUI is disabled at the beginning

That seemed to work thanks for the help!

1 Like