Enabling screen GUI through local script isn't working

I’m finalizing my main menu but one part doen’t work, so how my main menu works is that as soon as you load into the game, you are met with a loading screen (that loads everything obviously) then it shows a cutscene about what the game is about, with a play button on the bottom left of the screen, when the player clicks the “play” button it will show a transition screen and re-enable core GUI that was disabled during the loading screen and cut-scenes, from there it’ll show a team picking GUI, how it shows the team-picking-GUI is that it just enables the Screen GUI Container that contains all the GUI and scripts.
image
as you can see, “TeamChosingUI” is the ScreenGUI Container that i was talking about that i enable in-between the transition

well, half of it works, when you click the “play” button the core GUI is re-enabled but you can’t see the team-picking UI, even though the screenGUI container is enabled, you can’t see the UI, i checked if i left the UI’s visible to false, that wasn’t the case.
as you can see, after i press “play” and the play button disappears the “enabled” is true, but you can’t see the GUI


local playButton = script.Parent
local tween = game:GetService("TweenService")
local frame = script.Parent.Parent:WaitForChild("Frame")
playButton.TextTransparency = 0


--team chosing UI vars
local TCUI = game.StarterGui.TeamChoosingUI
[[--how to script works is if the player clicks the button "play" 
it'll tween a black frame's transparency to 1,
waits one second, then back to zero creating a cool transition scene, 
but after the first tween that sets the frames transparency
 to one (showing the whole black frame, it is suppose to enable the UI 
that shows the team picking, so when the black frame goes back to 1 transparency the player will see the team picking GUI. but it doesn't really do that.

--]]
local function freeplr()
	playButton.TextTransparency = 1
-variables for the tweens
	local o = tween:Create(frame,TweenInfo.new(1), {Transparency = 0})
	local t = tween:Create(frame,TweenInfo.new(1), {Transparency = 1})

	o:Play()
	wait(1)
	t:Play()
	playButton.Parent.Enabled = false
	if o.PlaybackState == Enum.PlaybackState.Completed then -- so once "o" is compeleted it will run this.
		TCUI.Enabled = true
		print("hi")
	end
--the code above is the important part
--this code below is just re-enabling core GUI that was disabled during the main menu cutscene.
	SG:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
	SG:SetCore("ResetButtonCallback",true)
	UIS.ModalEnabled = false
	UIS.MouseIconEnabled = true
end
playButton.MouseButton1Click:Connect(freeplr)

as you can see, everything works, except for the enabling part.
Desktop 2021 06 04 15 18 52 03 - YouTube

2 Likes

This is the commonly found StarterGui issue.
You are referencing the GUI in StarterGui. The GUI in StarterGui is cloned to individual players’ GUIs. Instead, use game.Players.LocalPlayer:WaitForChild("PlayerGui") instead of game.StarterGui, to get the GUI of the current player.

9 Likes

GUI is independently replicated to each client when the game runs.
There for this line of code here is referencing the wrong place.

local TCUI = game.StarterGui.TeamChoosingUI

you need something that references “PlayerGui” which is local player specific.

local TCUI = player.PlayerGui.TeamChoosingUI
-- something like this.
5 Likes