I am making a brick which when clicked a GUI will enlarge. When I hit the "close" button the GUI collapses. However when I re-open it after closing it opens larger than the first click, and proceeds to enlarge more and more. If this doesn't make sense then here is an example: When I hit open it opens through an animation where a GUI enlarges. Then I proceed to close it. After that I click open again and it enlarges to double its original size. I hope this makes sense, if so please help. Here is the opening GUI code:
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local Background = player.PlayerGui.PromptPurchase.Background
if game.Workspace.Data.Buildingname.Value == ("ArcherHut") then
for i = 0, 10, 1 do
wait(0.0001)
player.PlayerGui.PromptPurchase.Background.Size = UDim2.new(Background.Size.X.Scale + 0.04, 0, Background.Size.Y.Scale + 0.035, 0)
end
for i = 0, 5, 1 do
wait(0.0001)
player.PlayerGui.PromptPurchase.Background.Size = UDim2.new(Background.Size.X.Scale - 0.002, 0, Background.Size.Y.Scale - 0.002, 0)
end
end
end)
And here is the closing script:
script.Parent.MouseButton1Click:Connect(function()
for i = 0, 5, 1 do
wait(0.0001)
script.Parent.Parent.Size = UDim2.new(script.Parent.Parent.Size.X.Scale + 0.002, 0, script.Parent.Parent.Size.Y.Scale + 0.002, 0)
end
for i = 0, 10, 1 do
wait(0.0001)
script.Parent.Parent.Size = UDim2.new(script.Parent.Parent.Size.X.Scale - 0.04, 0,script.Parent.Parent.Size.Y.Scale - 0.035, 0)
end
end)
Thanks!
