Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't my script setting a value to false?

I'm making a help gui for new players, and I want a system where if you click the button that shows the help screen again after clicking it once already, it will stop showing it. This system isn't working and I don't know why. It does tween it back to it's original position when you click it again. But then if you try to click it a third time, nothing happens. Here's my code

local AlreadyClicked = false

script.Parent.MouseButton1Down:Connect(function()
	
	local HelpGUI = script.Parent.Parent.HelpGUI
	
	if AlreadyClicked == true then
		AlreadyClicked = false
		HelpGUI:TweenPosition(UDim2.new(-0.179, 0,0.306, 0),"Out","Quad",1,false)
	end
   
	
	
	
	HelpGUI:TweenPosition(
	                      UDim2.new(0.101, 0,0.309, 0),
		                  "Out",
		                  "Quad",
		                  1,
		                  false)
	                      
	AlreadyClicked = true
end)

1 answer

✓ Accepted answer

Try this

local HelpGUI = script.Parent.Parent.HelpGUI
local Close = true

local ShowUdim2 = UDim2.new(0.101, 0,0.309, 0)
local HideUdim2 = UDim2.new(-0.179, 0,0.306, 0)

script.Parent.MouseButton1Click:Connect(function()
	HelpGUI:TweenPosition(Close and ShowUdim2 or HideUdim2, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1, true)
	Close = (not Close)
end)

Hope this help, to more question put bellow in commentaries.

1 comment

0

Do you mind explaining why that works? It does works but I have no idea why.

This discussion is preserved as it was. New answers, comments, and votes are closed.