TweenService not working after pressing a button

Frame won’t go up and text won’t go up then both back down.

local button = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character:WaitForChild("Humanoid")
local leaderstats1 = player:WaitForChild("leaderstats"):WaitForChild("EggCoins")
local leaderstats2 = game.ReplicatedStorage.w1
local button2 = script.Parent.Parent.Parent.Three.TextLabel
local three = script.Parent.Parent
local four = script.Parent.Parent.Parent.Three.TextLabel
local originalposition = script.Parent.Parent.Position
local MaxEggdog = 1
local trigger = game.ReplicatedStorage:WaitForChild("TropicalEggdog")

if MaxEggdog > 1 then
	four.Text = "You can't buy more than one skin!"
	--copy tween service here
end


button.MouseButton1Click:Connect(function()
	if leaderstats1.Value >= 150 then
		--[[leaderstats2.Value = true
		button.Sound:Play()
		leaderstats.Value -= 150
	    trigger:FireServer()
	    MaxEggdog += 1
		script.Parent.Parent.Parent.Enabled = false ]]
		button.Sound:Play()
		local Info = TweenInfo.new(1.25, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out)
		local ts = game:GetService("TweenService")
		local db = false
		local tween4 = ts:Create(three, Info, {
			["Position"] = originalposition + UDim2.fromScale(0, -0.2)

		})
		local tween5 = ts:Create(four, Info, {
			["Position"] = UDim2.fromScale(0.25, 0.85) --1.5 later
		})
		if not db then
			db = true
			tween4:Play()
			tween5:Play()
			wait(3.5)
			local tween6 = ts:Create(three, Info, {
				["Position"] = originalposition - UDim2.fromScale(0, -0.2)

			})
			local tween7 = ts:Create(four, Info, {
				["Position"] = UDim2.fromScale(0.25, 1.5)
			})
			tween6:Play()
			tween7:Play()
			db = false
		end
	end
end)
1 Like

NEW script

local button = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character:WaitForChild("Humanoid")
local leaderstats1 = player:WaitForChild("leaderstats"):WaitForChild("EggCoins")
local leaderstats2 = game.ReplicatedStorage.w1
local button2 = script.Parent.Parent.Parent.Three.TextLabel
local three = script.Parent.Parent
local four = script.Parent.Parent.Parent.Three.TextLabel
local originalposition = script.Parent.Parent.Position
local MaxEggdog = 1
local trigger = game.ReplicatedStorage:WaitForChild("TropicalEggdog")

if MaxEggdog > 1 then
	four.Text = "You can't buy more than one skin!"
	--copy tween service here
end


button.MouseButton1Click:Connect(function()
	if leaderstats1.Value >= 150 then
		--[[leaderstats2.Value = true
		button.Sound:Play()
		leaderstats.Value -= 150
	    trigger:FireServer()
	    MaxEggdog += 1
		script.Parent.Parent.Parent.Enabled = false ]]
		button.Sound:Play()
		local Info = TweenInfo.new(1.25, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out)
		local ts = game:GetService("TweenService")
		local db = false
		if not db then
			db = true
			three:TweenSizeAndPosition(
				UDim2.new(0.9, 0,0.9, 0), -- size
				UDim2.new(0.07, 0,-0.1, 0), -- pos
				Enum.EasingDirection.Out, --easing dir
				Enum.EasingStyle.Sine, --easing styl
				1.25,
				true

			)
			four:TweenPosition(
				UDim2.new(0.25, 0,0.85, 0),
				Enum.EasingDirection.Out,
				Enum.EasingStyle.Sine,
				1.25,
				true
			)
			wait(3.5)
			three:TweenSizeAndPosition(
				UDim2.new(1, 0,1, 0), -- size
				UDim2.new(0, 0,0, 0), -- pos
				Enum.EasingDirection.Out, --easing dir
				Enum.EasingStyle.Sine, --easing styl
				1.25,
				true
			)
			four:TweenPosition(
				UDim2.new(0.25, 0,1.5, 0),
				Enum.EasingDirection.Out,
				Enum.EasingStyle.Sine,
				1.25,
				true
			)	
			db = false
		end
	end
end)

CONTEXT: I put some stuff like this because this is for testing.

Please provide a video of what the current state is and what you want to do.

I want the “YES” button to play a sound and tween up and theres a text hidden to tween up too and wait(3.5)
then everything goes back to where it is

When should it do that, if you got more than 1 egg or when you got more than 150 eggCoins

(Note it should be “An eggdog who is trying to relax”).

1 egg basically means how many times you bought it, if you bought it more than one time it just says max eggdog thing

eggcoins is a datastore thing
image

also the one egg thing should be ignored, im testing anyways.
I just want the MouseButton1Click function to be fixed

Alright so I suggest that you put prints basically everywhere (mainly per if statement), give them specific names with or without numbers. Then check which work and which dont.
Then after you’ll notice what does not work, put more if statements there.

Quick side note, you have to move

local db = false

Above the button.mouseButton1Click function, because well that will happen is every time you click it’ll be automatically set to db = false, so there is no cooldown first of all.

image
OK i tested it but nothing prints… whats the problem??