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
local db = false --debounce so no buggy

script.Parent.Parent.MouseEnter:connect(function() --mouse entered button parameters
    if not db then
        db = true
        for i = 0,-2,-0.05 do
            if script.Parent.Parent.MouseEnter == true then
                script.Parent.Position = UDim2.new(i,0,0.25,0)
                local GUIpos = script.Parent.Position.X.Scale --saves i value
                wait()
            else --if the mouse isn't touching the GUI...
                for x = GUIpos,0,0.05 do --saved value i is where it got left off
                    script.Parent.Position = UDim2.new(x,0,0.25,0) --does X go here??
                    wait()
                end
            end
        end
    end
    db = false
end)

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