Button Animation stop working when city is being deleted?

  1. What do you want to achieve? Keep it simple and clear!

So, I made a button animation that goes down and up when you click on it.

  1. What is the issue? Include screenshots / videos if possible!
  • No errors in the output

I have a city with tons of part which makes my game laggy. The button animation was working.

but the problem is when I delete the city the button animation stop working like it goes down but it doesn’t come back up.

local Play = script.Parent.DropShadow1:WaitForChild("Play")
local ButtonSound = workspace:WaitForChild("Button Sound Effect")

local function PlayOnClick()
	ButtonSound:Play()
	Play:TweenPosition(UDim2.new(0, 0,0, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .1, false)
	
	task.wait(0.01)
	Play.Position = UDim2.new(0, 0,-0.158, 0)
end
Play.MouseButton1Click:Connect(PlayOnClick)

local Store = script.Parent.DropShadow2:WaitForChild("Store")

local function StoreOnClick()
	ButtonSound:Play()
	Store:TweenPosition(UDim2.new(-0.004, 0,-0.031, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .1, false)

	task.wait(0.01)
	Store.Position = UDim2.new(-0, 0,-0.148, 0)
end
Store.MouseButton1Click:Connect(StoreOnClick)

local Setting = script.Parent.DropShadow3:WaitForChild("Setting")

local function SettingOnClick()
	ButtonSound:Play()
	Setting:TweenPosition(UDim2.new(-0, 0,-0.031, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .1, false)

	task.wait(0.01)
	Setting.Position = UDim2.new(-0, 0,-0.148, 0)
end
Setting.MouseButton1Click:Connect(SettingOnClick)

local Credit = script.Parent.DropShadow4:WaitForChild("Credit")

local function CreditOnClick()
	ButtonSound:Play()
	Credit:TweenPosition(UDim2.new(0.003, 0,-0.031, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .1, false)

	task.wait(0.01)
	Credit.Position = UDim2.new(-0, 0,-0.148, 0)
end
Credit.MouseButton1Click:Connect(CreditOnClick)
1 Like

What is the city button animation?

is not a city button animation is a animation for the main menu buttons.

the first video had city but the second is without it. So, when I delete the city the buttons stop working.

I need to see the code for deleting the city

I did it manually theres no code for it.

But thanks anyways I fixed it the wait was to short so it didn’t have enough time to react to the time and change the position which makes the button to not come back up.