Help with tweens

So I have this script that should move a GUI object off screen, ofc it doesnt work and I dont know why!

module.Functions['SlideBack'] = function(element:GuiObject,WaitBool)
	local tweens = {}
	local Amount = 0
	local Finished = 0
	
	local info = TweenInfo.new(0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
	
	for _, item in pairs(element:GetChildren()) do
		if item:IsA('GuiObject') then
			local position = UDim2.new(item.Position.X.Scale - item.Position.X.Scale,0,item.Position.Y.Scale,0)
			
			tweens[item.Name] = TweenService:Create(item,info, {Position = position})
			Amount += 1
		end
	end
	
	local function play(tween:Tween)
		tween:Play()
		tween.Completed:Wait()
		Finished += 1
	end
	
	for _, tween in pairs(tweens) do
		task.spawn(play,tween)
	end
	
	repeat task.wait() until Amount <= Finished or not WaitBool
	return
end

My guess is you just cant tween things off screen, if this is true how can I get the same effect?

4 Likes

If you can’t tween GUIs off screen then tween it’s size to barely anything.

1 Like

Just tween the gui near the end of the screen and make it not visible. Or if you want a nice effect do the same thing but make a transparency loop for a nice effect.

1 Like

Its already at the edge of the screen at default

1 Like

Are there any errors? If not, try adding a couple of print statements in the code to understand where the issue might be.

2 Likes

If I scale it down the text doesnt fit with it. Idk how to explain it

1 Like

no errors, I put print() every where they all printed

1 Like

Try entering your position yourself and check if the buttons move to another place?

1 Like

Would this video help:

https://m.youtube.com/watch?v=V_eqogNIYEg

I think the position you’re subtracting in the x-axis is 0, that’s why the window isn’t moving left. I believe you need to try subtracting its size instead.

local position = UDim2.new(item.Position.X.Scale - item.Size.X.Scale,0,item.Position.Y.Scale,0)
1 Like

Ohhh yes! I forgot I was trying to subtract it depending on the size of it! Thanks!

2 Likes

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