So I am practicing my scripting because I just learned Tweening. I tried to make an Inventory script where you press the letter "e" on your keyboard and the GUI comes down to the middle where you can see it but when I press "e" on my keyboard, the GUI won't show up. The output supposedly doesn't say that there is an error... Did I make any mistake in my script? (Down Below)
Script:
01 | player = game.Players.LocalPlayer |
02 |
03 | if player:GetMouse().KeyDown = = "e" then |
04 |
05 | -- High Position of Frame: {0.068, 0},{-0.781, 0} |
06 | -- Middle Position of Inventory: {0.068, 0},{0.077, 0} |
07 |
08 | Inventory = script.Parent.Inventory |
09 | Inventory.Visible = true |
10 | Inventory:TweenPosition { |
11 |
12 | UDim 2 ( 0.068 , 0 , 0.077 , 0 ), |
13 | Enum.EasingDirection.Out, |
14 | Enum.EasingStyle.Quad, |
15 | 0.5 , |
16 | false |
17 | } |
18 | end |
Mouse has been superseded by UserInputService and ContextActionService. Always refer to API reference pages to keep up to date with things.
01 | local userInputService = game:GetService( "UserInputService" ) |
02 | local Inventory = script.Parent.Inventory |
03 |
04 | userInputService.InputBegan:Connect( function (input) |
05 | if input.KeyCode = Enum.KeyCode.E then |
06 | Inventory.Visible = true |
07 | Inventory:TweenPosition { |
08 | UDim 2. new( 0.068 , 0 , 0.077 , 0 ), --your original script would've worked, all you were missing was .new after UDim2 |
09 | Enum.EasingDirection.Out, |
10 | Enum.EasingStyle.Quad, |
11 | 0.5 , |
12 | false |
13 | } |
14 | end |
15 | end ) |