- 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.
- 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)