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

Does TweenPosition work with scrolling frames?

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)

1 comment

0

You may want to do 'key:lower()' just to make sure it's lower case.

1 answer

✓ Accepted answer

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)

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