Unable to enable a gui in a local script

I want to set a certain screengui in playergui to enabled if a value is true. I think the script should be working, but for some reason it isn’t. I’ve tried everything I could think of, but it still isn’t working. This is the section of the script:

	if game.Workspace.CriminalAbility.Ability.Value == "Sprint" then
		local Player = game.Players.LocalPlayer
		ContextActionService:BindAction(ACTION_RUN, RunAbility, false, Enum.KeyCode.LeftShift)
		Uses = 2
		Player:WaitForChild("PlayerGui").CriminalGui:WaitForChild("RunGui").UsesGUI.Text = Uses
		Player:WaitForChild("PlayerGui").CriminalGui:WaitForChild("RunGui").Enabled = true
	end

The first part of the script works fine but for some reason it doesn’t enable the Gui for the player. Also, “CriminalGui” is a folder, not an actual screengui. The script outputs no errors.

hi mate where is the local script located in the explorer?

The local script is located in StarterPlayerScripts. The rest of the script works, but the only part that doesn’t is enabling the Gui.

Update:
For some reason, putting task.wait() before enabling the gui makes it work. This makes me think that there might be another script disabling it. But because it works for now, I will mark this as the solution.

1 Like