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!