01 | local UIS = game:GetService( "UserInputService" ) -- Service used to get the key pressed by a player |
02 | local Part = game.Workspace.Part |
03 | UIS.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 = Vector 3. new(- 4 , j, 0 ) |
14 | wait(. 01 ) |
15 | end |