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

Im making an E key-bind, How do I change the script so that the player has to Hold down E?

Asked by 6 years ago
01local UIS = game:GetService("UserInputService") -- Service used to get the key pressed by a player
02 local Part = game.Workspace.Part
03UIS.InputBegan:connect(function(input,gameProcessed)
04    if input.UserInputType == Enum.UserInputType.Keyboard then -- Checks if the player uses a Keyboard
05        if input.KeyCode == Enum.KeyCode.E then script.Parent.Sound:Play() wait(5) script.Parent.Sound:Stop() -- Checks if the player pressed the "E" key
06            if UIS:GetFocusedTextBox() == nil then -- Checks if the player is typing on a textbox like the chat... If not then...
07                for i,v in pairs(game.Workspace.NPCs:GetChildren()) do -- Finds all the children from the folder. In this case it will find all the NPCs
08                    local mag = (v.Torso.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude -- Makes a variable for the position between the character and the npc.
09                    if mag <= 10 then -- If the magnitude is less than or equal to 10 studs then
10                        print() --start of effect
11                            game.Workspace.ColorKey.BrickColor = BrickColor.new("Lime green")
12                         for j = 6,-7,-.5 do
13                            Part.Position = Vector3.new(-4, j, 0)
14                            wait(.01)
15                          end
View all 55 lines...
0
contextactionservice and userinputstate EXpodo1234ALT 18 — 6y

Answer this question