Easy. Here is what I would do.
01 | local ClonePart = game.ServerStorage.ClonePart |
02 | local Player = game.Players.LocalPlayer |
03 | local Character = Player.Character |
04 | local UIS = game:GetService( "UserInputService" ) |
06 | UIS.InputBegan:connect( function (key) |
08 | if key.KeyCode = Enum.KeyCode.E and partIn = = false then |
10 | newClone = ClonePart:Clone() |
11 | newClone.Parent = game.Workspace |
12 | neClone.CFrame = Character.HumanoidRootPart.CFrame + CFrame.new( 0 , 0 , 5 ) |
13 | clickDetector = Instance.new( "ClickDetector" ) |
14 | clickDetector.Parent = newClone |
15 | if clickDetector.Clicked = = true and partIn = = true then |
Ok, first off, ClonePart will be the part in ServerStorage, whatever the name of it would be. Player is obvious, any scripter will be familiar with the second line. The UIS I put in is a variable for the UserInputService, which can detect User Input, obviously. Then the function will run if any input is sensed, which has the title "key", which can be changed to any name. Then a variable called partIn is set to false. This variable will prevent a user from repeatidly cloning the part in. Then the If statement detects if the user presses "e" and if partIn == false. It then clones the part and makes it's parent the Workspace, it also makes it's CFrame the character's plus 5 in the z Axis. A click detector is also added in the part to be able to detect if you press the part, and it is parented to newClone. Then the next If Statement checks if you have clicked the part and partIn == true. it then destroys the part and makes partIn = false. I might have messed up on this script. Wow, lol, I just wrote that from the top of my head, lol. Again, I mite hav hadz de gramer orr sintax eror(lol).