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

Does TweenPosition work with scrolling frames?

Asked by 10 years ago

I am trying to make my scrolling frame slide in but it doesn't work. Is this because it's a scrolling frame or just because of my script. If you want to see my script here it is:

mouse = game.Players.LocalPlayer:GetMouse()
open = false

script.Parent.MouseButton1Down:connect(function()
    if open == false then
        open = true
        script.Parent.Parent.Frame:TweenPosition(UDim2.new(0.3,0,0.2,0),"In","Back",2,true)
    end
    if open == true then
        open = false
        script.Parent.Parent.Frame:TweenPosition(UDim2.new(0.3,0,1,0),"Out","Linear",1,true)
    end
end)

mouse.KeyDown:connect(function(key)
    if key == "q" then
        if open == false then
            open = true
            script.Parent.Parent.Frame:TweenPosition(UDim2.new(0.3,0,0.2,0),"In","Back",2,true)
        end
        if open == true then
            open = false
            script.Parent.Parent.Frame:TweenPosition(UDim2.new(0.3,0,1,0),"Out","Linear",1,true)
        end
    end
end)
0
You may want to do 'key:lower()' just to make sure it's lower case. Perci1 4988 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

Try this code below and see if it works. I changed it from 2 if statements to one if and elseif statement. I also changed the if open == true to if open and if open == false to if not open due to it being easier to read (but it does the same exact thing). Let me know if this works and if it doesn't work, tell me the error.

mouse = game.Players.LocalPlayer:GetMouse()
open = false

script.Parent.MouseButton1Down:connect(function()
    if not open then
        open = true
        script.Parent.Parent.Frame:TweenPosition(UDim2.new(0.3,0,0.2,0),"In","Back",2,true)
   elseif open then
      open = false
      script.Parent.Parent.Frame:TweenPosition(UDim2.new(0.3,0,1,0),"Out","Linear",1,true)
    end
end)

mouse.KeyDown:connect(function(key)
    if key == "q" then
        if not open then
            open = true
            script.Parent.Parent.Frame:TweenPosition(UDim2.new(0.3,0,0.2,0),"In","Back",2,true)
       elseif open then
            open = false
            script.Parent.Parent.Frame:TweenPosition(UDim2.new(0.3,0,1,0),"Out","Linear",1,true)
        end
    end
end)

Ad

Answer this question