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

Buggy function doesn't return to size if you play with it. Help me please?

This script is buggy, and when I put my mouse off of it, it glitches sometimes and doesnt tween it back to 0, where the x value is originally as the frame. I'd like to know if there's another function of some sort that sets it back to its original position.

JediFrame = script.Parent.Parent.Parent
DescFrame = JediFrame.Desc

script.Parent.MouseEnter:connect(function()
	script.Parent:TweenSizeAndPosition(UDim2.new( 0, 253, 0, 30), UDim2.new( 0, 0, 0, 30), "Out", "Elastic", 0.3)
	DescFrame:TweenSizeAndPosition(UDim2.new( 0, 150, 0, 280), UDim2.new(  0, -150, 0, 20), "Out", "Elastic", 0.5)
end)

Here's the glitch

script.Parent.MouseLeave:connect(function()
	script.Parent:TweenSizeAndPosition(UDim2.new( 0, 0, 0, 30), UDim2.new( 0, 0, 0, 30), "Out", "Elastic", 0.3)
	DescFrame:TweenSizeAndPosition(UDim2.new( 0, 150, 0, 277), UDim2.new(  0, -150, 0, 20), "Out", "Elastic", 0.5)
end)

2 comments

0

Code block please!

0

There, code blocked.

1 answer

✓ Accepted answer

You are probably leaving it before the tween can finish. Add true to the end of the function calls to allow the functions to override each other. Like this.

JediFrame = script.Parent.Parent.Parent
DescFrame = JediFrame.Desc

script.Parent.MouseEnter:connect(function()
    script.Parent:TweenSizeAndPosition(UDim2.new( 0, 253, 0, 30), UDim2.new( 0, 0, 0, 30), "Out", "Elastic", 0.3, true)
    DescFrame:TweenSizeAndPosition(UDim2.new( 0, 150, 0, 280), UDim2.new(  0, -150, 0, 20), "Out", "Elastic", 0.5, true)
end)

and

script.Parent.MouseLeave:connect(function()
    script.Parent:TweenSizeAndPosition(UDim2.new( 0, 0, 0, 30), UDim2.new( 0, 0, 0, 30), "Out", "Elastic", 0.3, true)
    DescFrame:TweenSizeAndPosition(UDim2.new( 0, 150, 0, 277), UDim2.new(  0, -150, 0, 20), "Out", "Elastic", 0.5, true)
end)

Hope that helps ^-^

1 comment

0

Well it helps for sure, but the issue is some stuff still will glitch. It's MouseLeave, a very buggy event.

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