Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Making a GUI animation, too hard to explain what I need, come look?

Asked by 8 years ago
01local db = false --debounce so no buggy
02 
03script.Parent.Parent.MouseEnter:connect(function() --mouse entered button parameters
04    if not db then
05        db = true
06        for i = 0,-2,-0.05 do
07            if script.Parent.Parent.MouseEnter == true then
08                script.Parent.Position = UDim2.new(i,0,0.25,0)
09                local GUIpos = script.Parent.Position.X.Scale --saves i value
10                wait()
11            else --if the mouse isn't touching the GUI...
12                for x = GUIpos,0,0.05 do --saved value i is where it got left off
13                    script.Parent.Position = UDim2.new(x,0,0.25,0) --does X go here??
14                    wait()
15                end
16            end
17        end
18    end
19    db = false
20end)

This script essentially waits on firing until the mouse enters the GUI button area.

A for loop begins after the debounce is called , and it checks if the mouse is still in the box area. If it is, then it changes the position to the for loop's 'i' variable. This check is made every run of the for loop, and when the first condition isn't fufilled (when the mouse is NOT in the GUI zone), it resorts to an else statement.

The else statement get's a local variable stated earlier in the for loop which has the most recent position of the GUI's X scale value (what I'm changing). It then calls in another for loop which returns the GUI to its normal position , but the X scale value is set to GUIpos. The new X scale value is referred to as X and is adjusted every wait().

This is super confusing, but that's the best I could explain it.

0
If you're changing the size, use TweenSize. Position, TweenPosition. Or both, TweenSizeAndPosition TheHospitalDev 1134 — 8y

Answer this question