TweenPosition isn't working!

The title says it all. There is a problem with my tweenposition function and I don’t know how.
It’s supposed to run when a remote event is fired! I even tried using print debugging. Here’s the code I have:

local Frame1 = script.Parent.Frame1
local Frame2 = script.Parent.Frame2
local RmtEvent = game.ReplicatedStorage.RemoteEvents.Cutscenes.CutsceneStart
local RmtEvent2 = game.ReplicatedStorage.RemoteEvents.Cutscenes.CutsceneEnd

function Check()
	if Frame1.Position == UDim2.new(0, 0, 0, 0) and Frame2.Position == UDim2.new(0, 0, 0.857, 0)then
		print("Gud")
	else
		print("Sorry Dude! :C")
	end
end

RmtEvent.OnClientEvent:Connect(function()
	Frame1:TweenPosition(UDim2.new(0, 0, 0, 0))
	Frame2:TweenPosition(UDim2.new(0, 0, 0.857, 0))
	Check()
end)

RmtEvent.OnClientEvent:Connect(function()
	Frame1:TweenPosition(UDim2.new(0, 0, -0.2, 0))
	Frame2:TweenPosition(UDim2.new(0, 0, 1.2, 0))
end)

I think you mean?

RmtEvent.OnClientEvent:Connect(function()
	Frame1:TweenPosition(UDim2.new(0, 0, 0, 0))
	Frame2:TweenPosition(UDim2.new(0, 0, 0.857, 0))
	Check()
end)

RmtEvent2.OnClientEvent:Connect(function() -- i think you meant to refer to that variable
	Frame1:TweenPosition(UDim2.new(0, 0, -0.2, 0))
	Frame2:TweenPosition(UDim2.new(0, 0, 1.2, 0))
end)
1 Like

Well, its the first one, actually. :slightly_frowning_face:

I could be wrong but I believe TweenPosition requires more arguments than just the position.
So TweenPosition should look something along the lines of

TweenPosition(udim2, easingDirection, easingStyle, time, override, callback)

Some of these are optional like the override and callback

To fix your code you’d do something along the lines of this

local Frame1 = script.Parent.Frame1
local Frame2 = script.Parent.Frame2
local RmtEvent = game.ReplicatedStorage.RemoteEvents.Cutscenes.CutsceneStart
local RmtEvent2 = game.ReplicatedStorage.RemoteEvents.Cutscenes.CutsceneEnd

function Check()
	if Frame1.Position == UDim2.new(0, 0, 0, 0) and Frame2.Position == UDim2.new(0, 0, 0.857, 0)then
		print("Gud")
	else
		print("Sorry Dude! :C")
	end
end

RmtEvent.OnClientEvent:Connect(function()
	Frame1:TweenPosition(UDim2.new(0, 0, 0, 0), , nil, nil, 0.5, true)
	Frame2:TweenPosition(UDim2.new(0, 0, 0.857, 0), , nil, nil, 0.5, true)
	Check()
end)

RmtEvent.OnClientEvent:Connect(function()
	Frame1:TweenPosition(UDim2.new(0, 0, -0.2, 0), , nil, nil, 0.5, true)
	Frame2:TweenPosition(UDim2.new(0, 0, 1.2, 0), nil, nil, 0.5, true)
end)

The reason I set override to true in this instance is just personally what I do and I don’t believe it matters too much.