What is wrong with my script?

I am trying to create a main menu using tweening and animations. I am running it from two scripts, and these scripts are supposed to enable/disable each other. Here are the scripts it will probably make a lot more sense what I’m trying to do if I just show you. Also a video will be attached showing what my problem is. Output shows nothing unusual.
VIDEO:

Script 1: This is essentially when the Buttons are in the normal form (with play in the middle)

local TweenService = game:GetService('TweenService')

local Up = script.Parent.ArrowUp
local Down = script.Parent.ArrowDown
local play = script.Parent.Play
local cm = script.Parent.Customize
local sm = script.Parent.StoryMode

if Up.TextTransparency == 0 and Down.TextTransparency == 0 then 
	script.Parent.ButtonSwitch2.Enabled = false
end
Up.MouseButton1Up:Connect(function()
	play:TweenPosition(UDim2.new(0.116, 0,0.611, 0), "Out", "Sine", 0.5, false
	)
	play:TweenSize(UDim2.new(0.113, 0, 0.077, 0), "Out", "Sine", 0.5, false
	)
	sm:TweenPosition(UDim2.new(0.097, 0, 0.448, 0), "Out", "Sine", 0.5, false
	)
	sm:TweenSize(UDim2.new(0.152, 0, 0.104, 0), "Out", "Sine", 0.5, false
	)
	cm:TweenPosition(UDim2.new(0.157, 0, 0.668, 0), "Out", "Sine", 0.1, false
	)
	cm:TweenSize(UDim2.new(0.046, 0, 0.022, 0), "Out", "Sine", 0.1, false
	)
	play.TextTransparency = 0.25
	sm.TextTransparency = 0
	Up.TextTransparency = 1 
	cm.TextTransparency = 1
end)

Down.MouseButton1Up:Connect(function()
	play:TweenPosition(UDim2.new(0.116, 0, 0.325, 0), "Out", "Sine", 0.5, false
	)
	play:TweenSize(UDim2.new(0.113, 0, 0.077, 0), "Out", "Sine", 0.5, false
	)
	cm:TweenPosition(UDim2.new(0.097, 0, 0.448, 0), "Out", "Sine", 0.5, false
	)
	cm:TweenSize(UDim2.new(0.152, 0, 0.104, 0), "Out", "Sine", 0.5, false
	)
	sm:TweenPosition(UDim2.new(0.157, 0, 0.287, 0), "Out", "Sine", 0.1, false
	)
	sm:TweenSize(UDim2.new(0.046, 0, 0.022, 0), "Out", "Sine", 0.1, false
	)
	play.TextTransparency = 0.25
	cm.TextTransparency = 0
	Down.TextTransparency = 1
	wait(0.1)
	sm.TextTransparency = 1
end)

Script 2: This script essentially is when the buttons aren’t in normal form, and I want them to return to their original positions when respective button is pressed.

local TweenService = game:GetService('TweenService')

local Up = script.Parent.ArrowUp
local Down = script.Parent.ArrowDown
local play = script.Parent.Play
local cm = script.Parent.Customize
local sm = script.Parent.StoryMode

if Up.TextTransparency == 1 then
	script.Parent.ButtonSwitch.Enabled = false
	Down.MouseButton1Up:Connect(function()
		play:TweenPosition(UDim2.new(0.097, 0, 0.448, 0), "Out", "Sine", 0.5, false
		)
		play:TweenSize(UDim2.new(0.152, 0, 0.448, 0), "Out", "Sine", 0.5, false
		)
		cm:TweenPosition(UDim2.new(0.116, 0, 0.611, 0), "Out", "Sine", 0.5, false
		)
		cm:TweenSize(UDim2.new(0.113, 0, 0.077, 0), "Out", "Sine", 0.5, false
		)
		sm:TweenPosition(UDim2.new(0.116, 0, 0.325, 0), "Out", "Sine", 0.5, false
		)
		sm:TweenSize(UDim2.new(0.113, 0, 0.077, 0), "Out", "Sine", 0.5, false
		)
		Down.TextTransparency = 0
		Up.TextTransparency = 0
		sm.TextTransparency = 0.25
		cm.TextTransparency = 0.25
		play.TextTransparency = 0
	end)
end

if Down.TextTransparency == 1 then 
	script.Parent.ButtonSwitch.Enabled = false
	Up.MouseButton1Up:Connect(function()
		play:TweenPosition(UDim2.new(0.097, 0, 0.448, 0), "Out", "Sine", 0.5, false
		)
		play:TweenSize(UDim2.new(0.152, 0, 0.448, 0), "Out", "Sine", 0.5, false
		)
		cm:TweenPosition(UDim2.new(0.116, 0, 0.611, 0), "Out", "Sine", 0.5, false
		)
		cm:TweenSize(UDim2.new(0.113, 0, 0.077, 0), "Out", "Sine", 0.5, false
		)
		sm:TweenPosition(UDim2.new(0.116, 0, 0.325, 0), "Out", "Sine", 0.5, false
		)
		sm:TweenSize(UDim2.new(0.113, 0, 0.077, 0), "Out", "Sine", 0.5, false
		)
		Down.TextTransparency = 0
		Up.TextTransparency = 0
		sm.TextTransparency = 0.25
		cm.TextTransparency = 0.25
		play.TextTransparency = 0
	end)
end

Hopefully, I properly explained what I’m trying to do. Any help I can get would be awesome. If I didn’t explain what I’m trying to do properly, please ask questions! PS: Ignore my buggy camera script I plan on fixing that lol. Also I know I could have used TweenSizeAndPosition but i didnt feel like it. If i should genuinely change that pls lmk tho!

1 Like

I figured it out myself guys dont worry! i realized i used a bad way to animate it to begin with. Heres the code that works now:

local ts = game:GetService("TweenService")
local pl = script.Parent.Play
local sm = script.Parent.StoryMode
local cm = script.Parent.Customize
local up = script.Parent.ArrowUp
local down = script.Parent.ArrowDown
local ti = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out) -- tween info!
local tid = TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out) -- tween info for when objects are dissapearing
-- wen up pressed tweens!
local tweenplay = ts:Create(pl, ti, {Position = UDim2.new(0.116, 0,0.611, 0), Size = UDim2.new(0.113, 0, 0.077, 0)}) -- play move from original
local tweensm = ts:Create(sm, ti, {Position = UDim2.new(0.097, 0, 0.448, 0), Size = UDim2.new(0.152, 0, 0.104, 0)}) -- sm move from original 
local tweencm = ts:Create(cm, tid, {Position = UDim2.new(0.157, 0, 0.668, 0), Size = UDim2.new(0.046, 0, 0.022, 0)}) -- cm go away
-- wen down pressed tweens!
local tweenplayd = ts:Create(pl, ti, {Position = UDim2.new(0.116, 0, 0.325, 0), Size = UDim2.new(0.113, 0, 0.077, 0)})
local tweensmd = ts:Create(sm, tid, {Position = UDim2.new(0.157, 0, 0.287, 0), Size = UDim2.new(0.046, 0, 0.022, 0)})
local tweencmd = ts:Create(cm, ti, {Position = UDim2.new(0.097, 0, 0.448, 0), Size = UDim2.new(0.152, 0, 0.104, 0)})
-- return tweens!
local tweenplayr = ts:Create(pl, ti, {Position = UDim2.new(0.097, 0, 0.448, 0), Size = UDim2.new(0.152, 0, 0.448, 0)})
local tweensmr = ts:Create(sm, ti, {Position = UDim2.new(0.116, 0, 0.325, 0), Size = UDim2.new(0.113, 0, 0.077, 0)})
local tweencmr = ts:Create(cm, ti, {Position = UDim2.new(0.116, 0, 0.611, 0), Size = UDim2.new(0.113, 0, 0.077, 0)})

-- wen up is pressed (:
up.MouseButton1Up:Connect(function()
	if up.TextTransparency == 0 and down.TextTransparency == 0 then 
		tweenplay:Play()
		tweensm:Play()
		tweencm:Play()
		pl.TextTransparency = 0.25
		sm.TextTransparency = 0
		up.TextTransparency = 1
		up.Visible = false
		cm.TextTransparency = 1
	end
	if down.TextTransparency == 1 then
		tweenplayr:Play()
		tweensmr:Play()
		tweencmr:Play()
		pl.TextTransparency = 0
		cm.TextTransparency = 0.25
		sm.TextTransparency = 0.25
		up.TextTransparency = 0
		down.TextTransparency = 0
		down.Visible = true
	end
end)
-- wen down is pressed (:
down.MouseButton1Up:Connect(function()
	if up.TextTransparency == 0 and down.TextTransparency == 0 then
		tweenplayd:Play()
		tweensmd:Play()
		tweencmd:Play()
		pl.TextTransparency = 0.25
		cm.TextTransparency = 0
		down.TextTransparency = 1
		down.Visible = false
		sm.TextTransparency = 1
	end
	if up.TextTransparency == 1 then
		tweenplayr:Play()
		tweensmr:Play()
		tweencmr:Play()
		pl.TextTransparency = 0
		cm.TextTransparency = 0.25
		sm.TextTransparency = 0.25
		up.TextTransparency = 0
		up.Visible = true
		down.TextTransparency = 0
	end
end)


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.