I'm trying to create a shop GUI for computer player's and since the games in first person a button that you would normally use can't be clicked (unless you are on mobile.) So I decided to use a KeyDown function so every time the player hits "q" the Frame from the GUI will appear along with a smooth animation.
Unfortunately, when the player hits "q" It comes on to the player's screen but only stays there even after you press "q" for it to close. I'm only fairly new to scripting so It's probably some minor error.
----------SCRIPT----------
local toggle = false local frame = script.Parent.Parent:WaitForChild('SHOP').Frame
Player = game.Players.LocalPlayer Mouse = Player:GetMouse() gui = script.Parent frame = gui.Frame
function PressS(key) -- Starts the function if(key == "s")then
frame:TweenPosition(UDim2.new(0.5,-250,0.5,-200),'Out', 'Bounce', 1) -- Tween's up onto players screen toggle = true frame:TweenPosition(UDim2.new(0.5,-250,1.7,-200),'Out', 'Bounce', 1) -- Tween's off the players screen toggle = false end
end
Mouse.KeyDown:connect(PressS)
You're missing the toggle check, do something like this:
frame:TweenPosition(UDim2.new(0.5,-250,toggle and 1.7 or .5,-200),'Out', 'Bounce', 1) toggle = not toggle