Menu scripting problem

Thank you in advance for answering. I have started scripting some days ago so if my question already has an obvious answer, then I apologize for my ignorance.

  1. What do you want to achieve?
    I want to make that BackgroundTransparency appears ONLY after the menu opens

  2. What is the issue?
    The BackgroundTransparency is running when the menu it isn´t open

  3. What solutions have you tried so far?
    I have search for the answer in videos and in the forum but I haven´t find this specifically answer

--//Services//--
local Tween = game:GetService("TweenService")

--//Frame Variables//--
local CharacterSelectFrame = script.Parent:WaitForChild("CharacterSelectFrame")

--//Variables//--
local NCS = CharacterSelectFrame:WaitForChild("NarutoCharacterSelect")
local NCI = CharacterSelectFrame:WaitForChild("NarutoCharacterImage")
local NCB = CharacterSelectFrame:WaitForChild("NarutoCharacterBelow")
local SelectCharacter = script.Parent:WaitForChild("SelectCharacter")
local CSFIsOpen = false

--//Tweens//--
local CSFPopIn = Tween:Create(CharacterSelectFrame, TweenInfo.new(0.3, Enum.EasingStyle.Sine), {Transparency = 0.5})
local CSFPopOut = Tween:Create(CharacterSelectFrame, TweenInfo.new(0.3, Enum.EasingStyle.Sine), {Transparency = 1})
local NCSPopIn = Tween:Create(NCS, TweenInfo.new(0.3, Enum.EasingStyle.Sine), {TextTransparency = 0})
local NCSPopOut = Tween:Create(NCS, TweenInfo.new(0.3, Enum.EasingStyle.Sine), {TextTransparency = 1})
local NCIPopIn = Tween:Create(NCI, TweenInfo.new(0.3, Enum.EasingStyle.Sine), {ImageTransparency = 0})
local NCIPopOut = Tween:Create(NCI, TweenInfo.new(0.3, Enum.EasingStyle.Sine), {ImageTransparency = 1})
local NCBPopIn = Tween:Create(NCB, TweenInfo.new(0.3, Enum.EasingStyle.Sine), {TextTransparency = 0})
local NCBPopOut = Tween:Create(NCB, TweenInfo.new(0.3, Enum.EasingStyle.Sine), {TextTransparency = 1})

--//SelectCharacter//--
SelectCharacter.MouseButton1Click:Connect(function()
	CSFIsOpen = not CSFIsOpen
	if CSFIsOpen then
		--//Open//--
		CSFPopIn:Play()
		NCSPopIn:Play()
		NCIPopIn:Play()
		NCBPopIn:Play()
	else
		--//Close//--
		CSFPopOut:Play()
		NCSPopOut:Play()
		NCIPopOut:Play()
		NCBPopOut:Play()
	end	
end)

NCI.MouseEnter:Connect(function()
	NCI.BackgroundTransparency = 0.5
end)

NCI.MouseLeave:Connect(function()
	NCI.BackgroundTransparency = 1
end)
1 Like

I suggest making these lines don’t fire while the menu isn’t open. You could make an if statement to check if the menu is disabled or not.

2 Likes

I already tried that, but when I made that, the BackgroundTransparency even not appear in both moments

1 Like

Have you tried something like this?

NCI.MouseEnter:Connect(function()
    if CSFIsOpen then
	    NCI.BackgroundTransparency = 0.5
    end
end)

NCI.MouseLeave:Connect(function()
    -- Don't need to check if menu is open, because we probably want to make it invisible anyway when the mouse leaves.
    NCI.BackgroundTransparency = 1
end)

Another thing, you should probably be using the .Visible property to toggle visibility of the whole menu. That way, children and descendants of the menu will also become invisible when you set menu.Visible to false, regardless of their BackgroundTransparency.

1 Like