In my game, I am adding an ATM system to the game, I am doing this by having the UI contain a BoolValue that dictates whether the UI is open or closed, and a localscript that checks if the value is changed, and if it is, tweens the UI onto the screen, and when it is closed, tweens it off of the screen and sets visible to false.
The problem that I’m having is, the script is triggering correctly on the first opening of the UI, and then allowing it to close, but then afterwards is not allowing the UI to show again.
Code
Here is the LoclScript for the script that triggers when the BoolValue is changed
local TweenService = game:GetService("TweenService")
local isVisible = script.Parent.isVisible
isVisible.Changed:Connect(function()
if isVisible.Value == false then
local TweenInfo = TweenInfo.new(2)
local goal = {}
goal.Position = UDim2.new(0.5,0,2,0)
local CloseTween = TweenService:Create(script.Parent, TweenInfo, goal)
CloseTween:Play()
CloseTween.Completed:Connect(function()
script.Parent.Visible = false
end)
else
script.Parent.Visible = true
script.Parent.Position = UDim2.new(0.5,0,2,0)
local TweenInfo = TweenInfo.new(2)
local goal = {}
goal.Position = UDim2.new(0.5,0,0.5,0)
local OpenTween = TweenService:Create(script.Parent, TweenInfo, goal)
OpenTween:Play()
end
end)
script.Parent.CloseButton.MouseButton1Click:Connect(function()
script.Parent.isVisible.Value = false
end)
Here is the Script under the click detector to set the BoolValue to true
script.Parent.MouseClick:Connect(function(player)
player.PlayerGui.ATMSystem.ATMFrame.isVisible.Value = true
end)