Advertisement
plytalent

PlayerMouseLocal

Dec 17th, 2020
931
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. local player = game:GetService("Players").LocalPlayer
  2. local mouse = player:GetMouse()
  3. local KeyDownRemote = script.Parent:WaitForChild("KeyDown")
  4. local KeyUpRemote = script.Parent:WaitForChild("KeyUp")
  5. local Button1DownRemote = script.Parent:WaitForChild("Button1Down")
  6. local Button1UpRemote = script.Parent:WaitForChild("Button1Up")
  7. local MoveRemote = script.Parent:WaitForChild("Move")
  8. local HitRemote,TargetRemote = script.Parent:WaitForChild("Hit"),script.Parent:WaitForChild("Target")
  9.  
  10. mouse.KeyDown:Connect(function(k)KeyDownRemote:FireServer(k)end)
  11. mouse.KeyUp:Connect(function(k)KeyUpRemote:FireServer(k)end)
  12. mouse.Button1Down:Connect(function(k)KeyDownRemote:FireServer(k)end)
  13. mouse.Button1Up:Connect(function(k)KeyUpRemote:FireServer(k)end)
  14. mouse.Move:Connect(function()MoveRemote:FireServer()end)
  15.  
  16. local old={Hit=mouse.Hit,Target=mouse.Target}
  17.  
  18. game:GetService("RunService"):BindToRenderStep("CHECKING MOUSE HIT AND TARGET",101,function()
  19.     coroutine.resume(coroutine.create(function()
  20.         if mouse["Hit"] ~= old["Hit"] then
  21.             old["Hit"] = mouse.Hit
  22.             HitRemote:FireServer(mouse.Hit)
  23.         end
  24.     end))
  25.     coroutine.resume(coroutine.create(function()
  26.         if mouse["Target"]~= old["Target"] then
  27.             old["Target"]=mouse.Target
  28.             TargetRemote:FireServer(mouse.Target)
  29.         end
  30.     end))
  31. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement