Advertisement
HowToRoblox

InputDetector

Jul 11th, 2021
2,146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.66 KB | None | 0 0
  1. local uis = game:GetService("UserInputService")
  2.  
  3. local mouse = game.Players.LocalPlayer:GetMouse()
  4.  
  5. local cam = workspace.CurrentCamera
  6.  
  7.  
  8. local re = game.ReplicatedStorage:WaitForChild("CreateLighting")
  9.  
  10.  
  11. local holding = false
  12.  
  13.  
  14.  
  15. uis.InputBegan:Connect(function(inp, processed)
  16.    
  17.     if processed then return end
  18.    
  19.    
  20.     if inp.KeyCode == Enum.KeyCode.F then
  21.        
  22.         holding = true
  23.     end
  24. end)
  25.  
  26.  
  27. uis.InputEnded:Connect(function(inp)
  28.    
  29.    
  30.     if inp.KeyCode == Enum.KeyCode.F then
  31.        
  32.         holding = false
  33.     end
  34. end)
  35.  
  36.  
  37. game:GetService("RunService").Heartbeat:Connect(function()
  38.    
  39.    
  40.     if holding then
  41.        
  42.         re:FireServer(mouse.Hit, cam.CFrame)
  43.     end
  44. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement