Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

TweenPosition doesn't work and idk why??

Here is my code:

script.Parent.inv.MouseButton1Click:connect(function()
	local inventory = script.Parent.Parent.inventory
	inventory.Visible = true
inventory:TweenPosition(UDim2.new(0.01, 0, 0.1, 0), "Out", "Bounce", 1.2)
end)

That part works, but this part doesnt:

script.Parent.close.MouseButton1Click:connect(function()
	script.Parent:TweenPosition(UDim2.new(0, -100,0.098, 0),"Out", "Elastic", 1.2)
	script.Parent.Visible = false
end)

The position i set for the frame is 0, -100,0.098,0 btw. pls help!

1 answer

TweenPosition does not yield, which means that it is set to be invisible immediately after you call TweenPosition. TweenPosition has an optional callback as its sixth argument, which is what you may need.

script.Parent.close.MouseButton1Click:connect(function()
	script.Parent:TweenPosition(
		UDim2.new(0, -100,0.098, 0),
		"Out",
		"Elastic",
		1.2,
		true, -- I'm guessing you want it to override any previous tweens.
		function() -- callback, call this function whenever the tween ends or gets cancelled.
    			script.Parent.Visible = false
	end)
end)

2 comments

0

thanks

0

Accept answers!

This discussion is preserved as it was. New answers, comments, and votes are closed.