Frame is not getting visible

Currently reworking my LoadingScreen.
I want to achieve, that I can open the StartMenu again with the KeyCode M. It is opening when the player joins and that works fine, but when I try it with the KeyCode, the Frame will just not be visible to me, even if in the PlayerGui, Enabled is on.

function MenuStart()
	StartMenu.Visible = true
	print("Visible") --Is printed everytime it should print
	task.wait(0.5)
	BodyAnchor(1)
	location = "Start"

	repeat
		task.wait(0.5)
	until
	UIS.MouseIconEnabled == true
	inMenu = true
end

rep.OnClientEvent:Connect(function() --When player joins it fires which works fine
	MenuStart()
end)

UIS.InputBegan:Connect(function(input) --The KeyCode tetection
	if input.KeyCode == Enum.KeyCode.M then
		MenuStart()
	end
end)


-------------------------------------------------

Play.MouseButton1Click:Connect(function()
	if inMenu == true and location == "Start" then
		for i, v in pairs(StartMenu:GetDescendants()) do
			local tweenInfo = TweenInfo.new(2)
			local targetTransparency = 1
			if v:IsA("UIStroke") then
				local StartTween = TweenS:Create(v, tweenInfo, {Transparency = targetTransparency})
				StartTween:Play()
			elseif v:IsA("TextLabel") then
				local StartTween = TweenS:Create(v, tweenInfo, {TextTransparency = targetTransparency})
				StartTween:Play()
			elseif v:IsA("ImageLabel") then
				local StartTween = TweenS:Create(v, tweenInfo, {ImageTransparency = targetTransparency})
				StartTween:Play()
			elseif v:IsA("TextButton") then
				local StartTween1 = TweenS:Create(v, tweenInfo, {TextTransparency = targetTransparency})
				local StartTween2 = TweenS:Create(v, tweenInfo, {BackgroundTransparency = targetTransparency})
				StartTween1:Play()
				StartTween2:Play()		
			end
		end	
		task.wait(2)
		StartMenu.Visible = false
		inMenu = false
		BodyAnchor()
	end
end)

--This is the local script part where the GUI gets invisible when you press play when the UI is visible when player joins.

Its a Local Script parented inside of the ScreenGui of the Frame in StarterGui.

Since it prints visible, the problem is probably the BodyAnchor function or something making it so you can’t run the function twice.

Also, I just wanted to ask, why do you have it start off of an event?

rep.OnClientEvent:Connect(function() --When player joins it fires which works fine
	MenuStart()
end)

Could just be

MenuStart()

You could just repeat task.wait() until game:IsLoaded() if you were worried about that because the client script will run the MenuStart once it’s added.

To the BodyAnchor:

function BodyAnchor(method)
	if method == 1 then
		hum.LeftLeg.Anchored = true
		hum.RightLeg.Anchored = true
		hum.Torso.Anchored = true
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
	elseif inMenu == true then
		hum.LeftLeg.Anchored = true
		hum.RightLeg.Anchored = true
		hum.Torso.Anchored = true
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
	else
		hum.LeftLeg.Anchored = false
		hum.RightLeg.Anchored = false
		hum.Torso.Anchored = false
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
	end
end

And to your second question, the rep Event is an Event coming from a ServerScript when a player joins so the UI gets visible when a player joins and that works totally fine. Only when trying to open the UI with the UIS, its not working. And since the player is not respawning and the code worked before, repeating until game has loaded doesnt makes sense

Put prints inside of the bodyanchor, to see where it’s reaching to, so one before the if statement, then one in each, I think it could be something with the

game.StarterGui:SetCoreGuiEnabled(Enum.CoreguiType.All, false)

The BodyAnchor function is going through succesfully without problems. But a thing that I noticed, in the StartMenu are buttons for other menu frames and I can click them and the corresponding menu is actually opening. Thats so weird… Here is btw a pic of my workspace

image
(I managed to open the Credits Frame with the CreditButton)

Got it fixed. The Tweening made the TRANSPARENCY to 1 and not a boolean like visible.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.