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

How can I make a gui animation trigger when a certain key is pressed?

Asked by 9 years ago

This is the one I tried making but didnt work can anybody help me find a tutorial or even help me themselves?

local Frame = script.Parent.Frame
02
local Box = Frame.Box
03
local Button = Frame.Button
04

05

06
Player = script.Parent.Parent
07
mouse = Player:GetMouse()
08

09

10
local Animate = function(Frame, EndPos, EndSize, Direction, Style, Time, OR, Type) -- Frame, UDim2, easingDirection, easingStyle, float [time], bool [override], TypeOfAnimation
11
    if Type == "Position" then
12
        return Frame:TweenPosition(EndPos, Direction, Style, Time, OR)
13
    elseif Type == "Size" then
14
        return Frame:TweenSize(EndSize, Direction, Style, Time, OR)
15
    elseif Type == "SizeAndPosition" then
16
        return Frame:TweenSizeAndPosition(EndPos, EndSize, Direction, Style, Time, OR)
17
    end
18
end
19

20
function onKeyDown(key)
21
    key = key:lower()
22
if script.Parent.Open.Value == false then
23
    if key == "e" then
24
Box.Position = UDim2.new(-2,0,0,0)
25
Animate(Box,UDim2.new(0.150,0,0,0), UDim2.new(0.25, 0, 0.25, 0), "Out", "Back", 2, true, "Position")
26
        end
27
    end
28
end
29

30
mouse.KeyDown:connect(onKeydown)

1
1. Take out the numbers. 2. The proper method from a local script to get a player is game.Players.LocalPlayer. 3. You shouldn't need to return the GUI animations. 4. Any output? ZeptixBlade 215 — 9y
0
it worked before I just edited it to try to make it so I can press a key to make the animation for the gui activate. The spots I changed are 39-59 AWESOMEnoob3 3 — 9y
0
Take out the numbers in the script. RAYAN1565 691 — 9y

Answer this question