Gui Position Problem

I made a script that works, but in the end the button doesn’t change position(script.Parent).
I tried everything I could think of but I have now ended up looking for a solution in the devforum

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.LocationFrame.Visible = true
	
	script.Parent.Parent.Ad:TweenSizeAndPosition(UDim2.new(0.5, 0,0.5, 0),UDim2.new(0.25, 0,0.17, 0),Enum.EasingDirection.In,Enum.EasingStyle.Sine,0.5)
	script.Parent:TweenPosition(UDim2.new(0,0,1,0))
	for i = 1, 20 do
		script.Parent.Parent.Ad.ImageTransparency = script.Parent.Parent.Ad.ImageTransparency + 0.1
		wait(0.01)
	end
	script.Parent.Parent.Visible = false
	script.Parent.Parent.Ad.Position = UDim2.new(0,0,0,0)
	script.Parent.Parent.Ad.Size = UDim2.new(1,0,0.77,0)
	script.Parent.Parent.Ad.ImageTransparency = 0
	script.Parent.Position = UDim2.new(0, 0,0.77, 0)
end)

At the end of the lines that you are tweening, you need to put :Play()

2 Likes

The tweening works. The problem is in the last line
(script.Parent.Position = UDim2.new(0, 0,0.77, 0)

It’s because you are changing the position while the tween is playing, try this:

script.Parent.TextButton.MouseButton1Click:Connect(function()
	
	script.Parent.Ad:TweenSizeAndPosition(UDim2.new(0.5, 0,0.5, 0),UDim2.new(0.25, 0,0.17, 0),Enum.EasingDirection.In,Enum.EasingStyle.Sine,0.5)
	script.Parent:TweenPosition(UDim2.new(0,0,1,0))
	for i = 1, 20 do
		script.Parent.Ad.ImageTransparency = script.Parent.Ad.ImageTransparency + 0.1
		wait(0.01)
	end
	script.Parent.Visible = true
	script.Parent.Ad.Position = UDim2.new(0,0,0,0)
	script.Parent.Ad.Size = UDim2.new(1,0,0.77,0)
	script.Parent.Ad.ImageTransparency = 0
	
	task.wait(5)
	
	script.Parent.Position = UDim2.new(0, 0,0.77, 0)
end)

you can change the wait time

task.wait(5)

I think this might be the problem I will try it tomorrow.

1 Like

Yes, now the position changes back to the original. Thank you!

1 Like

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