Hi, Im trying to make a Gui wich activates on pressing M. the script works perfectly I just don't know how to make it so it cant be interupted? Because if I press M a couple of time it breaks. With this i mean that M does nothing when the Gui is animating on the screen. Thanks in advance.
01 | local Travel = script.Parent.Parent.Travel |
02 |
03 | p = game.Players.LocalPlayer |
04 | mouse = p:GetMouse() |
05 |
06 | mouse.KeyDown:connect( function (key) |
07 | if key = = "m" then |
08 | if Travel.Visible = = true then |
09 | Travel:TweenPosition( |
10 | UDim 2. new( 0 , 0 , 0.79 , 0 ), --End Position |
11 | "Out" , -- Easing Direction |
12 | "Back" , --Easing Style |
13 | 2 , --How Long Does It Take? |
14 | false --Other Tween Override |
15 | ) |
I think a boolean would be applicable to this situation. The player will be unable to spam while the tween is playing.
01 | local Travel = script.Parent.Parent.Travel |
02 | p = game.Players.LocalPlayer |
03 | mouse = p:GetMouse() |
04 | local canPress = true |
05 |
06 | mouse.KeyDown:connect( function (key) |
07 | if not canPress then -- detect if player can press m |
08 | return -- return nothing if they can't |
09 | end |
10 | canPress = false -- set canPress to false |
11 | if key = = "m" then |
12 | if Travel.Visible = = true then |
13 | Travel:TweenPosition( |
14 | UDim 2. new( 0 , 0 , 0.79 , 0 ), --End Position |
15 | "Out" , -- Easing Direction |