A simple script wont run and gives me an error

Ok so my script won’t run and its Very Simple! And this is the error I get

Players.Koolkp5.PlayerGui.PlayerGUIYes.Frameformore.TeamsBttn.LocalScript:45: Incomplete statement: expected assignment or a function call

local TeamsFrame1 = script.Parent.Parent.Parent.TeamsFrame1

local Close = TeamsFrame1:TweenPosition( 
	UDim2.new(1.0, 0, 0.229, 0),
	"Out",
	"Back",
	1,
	false
)


local Open = TeamsFrame1:TweenPosition(
	UDim2.new(0.777, 0, 0.229, 0),
	"Out",
	"Back",
	1,
	false
)

This is the line that is giving me the error.

if Close then
		Open -- This is the line that gives me the error
	else
		Close -- This line has a red line under it
	end

I don’t know if I’m just being dumb right now. But I don’t see why I gives me a error.

1 Like

I’d use TweenService for this rather than UIObject:TweenPosition().

A TweenService implementation would look something like this:

local TweenService = game:GetService("TweenService")
local TeamsFrame1 = script.Parent.Parent.Parent.TeamsFrame1

local CloseTween = TweenService:Create(TeamsFrame1,TweenInfo.new(1),
    {Position = UDim2.new(1,0,0.229,0)}
)
local OpenTween = TweenService:Create(TeamsFrame1,TweenInfo.new(1),
    {Position = UDim2.new(0.777,0,0.229,0)}
)

if Close then
    OpenTween:Play()
else
    CloseTween:Play()
end
1 Like

Can you provide the entire script for more context? Thanks.

Yup!

local SettingsframeforPlayer = script.Parent.Parent.Parent.SettingsframeforPlayer

local TeamsBttn2 = script.Parent.Parent.TeamsBttn2

local TeamsFrame1 = script.Parent.Parent.Parent.TeamsFrame1

local Close = TeamsFrame1:TweenPosition( 
	UDim2.new(1.0, 0, 0.229, 0),
	"Out",
	"Back",
	1,
	false
)


local Open = TeamsFrame1:TweenPosition(
	UDim2.new(0.777, 0, 0.229, 0),
	"Out",
	"Back",
	1,
	false
)


script.Parent.MouseButton1Click:Connect(function()
	
		if  TeamsFrame1:TweenPosition(
			UDim2.new(0.777, 0, 0.229, 0),
			"Out",
			"Back",
			1,
			false
	)then
	
	SettingsframeforPlayer:TweenPosition(
		UDim2.new(1, 0, 0.229, 0),
		"Out",
		"Back",
		1,
		false
		)
	end
	
			if Close then
			Open
		else
			Close
		end
	
end)
1 Like
local SettingsframeforPlayer = script.Parent.Parent.Parent.SettingsframeforPlayer
local TeamsBttn2 = script.Parent.Parent.TeamsBttn2
local TeamsFrame1 = script.Parent.Parent.Parent.TeamsFrame1
local toggle = false
local debounce1 = false
local debounce2 = false

script.Parent.MouseButton1Click:Connect(function()
	SettingsframeforPlayer:TweenPosition(
		UDim2.new(1, 0, 0.229, 0),
		"Out",
		"Back",
		1,
		false
	)
	
	if not toggle then
		if debounce1 then
			return
		end
		debounce1 = true
		toggle = true
		TeamsFrame1:TweenPosition(
			UDim2.new(0.777, 0, 0.229, 0),
			"Out",
			"Back",
			1,
			false
		)
		task.wait(1)
		debounce1 = false
	elseif toggle then
		if debounce2 then
			return
		end
		debounce2 = true
		toggle = false
		TeamsFrame1:TweenPosition( 
			UDim2.new(1.0, 0, 0.229, 0),
			"Out",
			"Back",
			1,
			false
		)
		task.wait(1)
		debounce2 = false
	end
end)
1 Like