GUI wont enable

So I have a bank GUI that should show up when you touch a part and will disappear when you stop touching the part. What happens is you touch the part and the GUI pops up and when you stop touching it, it will go away BUT when I touch the part again it wont renable.

It is not enabling in the properties tab and there were no errors. Here is the code:

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildWhichIsA(“Humanoid”) and debounce == false then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
debounce = true

	print(player.Name)
	player.PlayerGui.Bank.Enabled = true
	player.PlayerGui.Bank.StartPrompt.Position = UDim2.new(0.457, 0,0.973, 0)
	player.PlayerGui.Bank.StartPrompt.Visible = true
		
		
		local TweenService = game:GetService("TweenService")
		local gui = player.PlayerGui.Bank.StartPrompt
		local tweenTime = 0.5
		
		local Info = TweenInfo.new(
			tweenTime,
			Enum.EasingStyle.Bounce,
			Enum.EasingDirection.Out,
			0,
			false,
			0
		)
		
		local Goals = 
		{
			Position = UDim2.new(0.457, 0,0.454, 0),				
		}
		
		local tween1 = TweenService:Create(gui, Info, Goals)
		tween1:Play()
		print("Tween ran!")
		wait(tweenTime)
		print("Tween ended!")
		local debounce = false
end		-- End of tween

end)

script.Parent.TouchEnded:Connect(function(hit)
if hit.Parent:FindFirstChildWhichIsA(“Humanoid”) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)

	player.PlayerGui.Bank.Enabled = false
		print("Ended!")
	-- End of tween	
	wait(1)
end

end)

Thanks for reading! :smiling_face_with_three_hearts:

1 Like

Is this being done on one singular script or two separate scripts?

If you are opening the GUI on a server script and closing it on a local script this means that the server will still register the GUI as being open and therefore won’t change it, whilst on the client the GUI will remain closed as the client has closed the GUI.

1 Like

One script. Its just weird formatting.

30 characters.

Try to fix the formatting by highlighting all the code and pressing the performat button two times, that should hopefully fix that issue.

As for your code, get rid of that local, not to sure that is your problem, but also check the position and make sure the frame is moving to the correct position.

Edit: it is also best to check for the player

2 Likes

The bank wont enable in the properties window. That seems to be the problem. :confused:

Where in your script are you defining Debounce?

1 Like

The very top
30 character hate

As I said up top get rid of that local in front of the debounce variable inside of the touched function. Also are there any errors in the output?