Advertisement
plytalent

Untitled

Jun 15th, 2019
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. --script (server side script)
  2. wait(3)
  3. local Player = game:GetService("Players").plytalent--<=== Replace With Your Name
  4.  
  5. local Mouse,mouse,UserInputService,ContextActionService
  6. do
  7. script.Parent = Player.Character
  8. local CAS = {Actions={}}
  9. local Event = Instance.new("RemoteEvent")
  10. Event.Name = "UserInput_Event(loaded)"
  11. Event.Parent = Player.Character
  12. local fakeEvent = function()
  13. local t = {_fakeEvent=true}
  14. t.Connect = function(self,f)self.Function=f end
  15. t.connect = t.Connect
  16. return t
  17. end
  18. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  19. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  20. function CAS:BindAction(name,fun,touch,...)
  21. CAS.Actions[name] = {Name=name,Function=fun,Keys={...}}
  22. end
  23. function CAS:UnbindAction(name)
  24. CAS.Actions[name] = nil
  25. end
  26. local function te(self,ev,...)
  27. local t = m[ev]
  28. if t and t._fakeEvent and t.Function then
  29. t.Function(...)
  30. end
  31. end
  32. m.TrigEvent = te
  33. UIS.TrigEvent = te
  34. Event.OnServerEvent:Connect(function(plr,io)
  35. if plr~=Player then return end
  36. if io.isMouse then
  37. m.Target = io.Target
  38. m.Hit = io.Hit
  39. elseif io.UserInputType == Enum.UserInputType.MouseButton1 then
  40. if io.UserInputState == Enum.UserInputState.Begin then
  41. m:TrigEvent("Button1Down")
  42. else
  43. m:TrigEvent("Button1Up")
  44. end
  45. else
  46. for n,t in pairs(CAS.Actions) do
  47. for _,k in pairs(t.Keys) do
  48. if k==io.KeyCode then
  49. t.Function(t.Name,io.UserInputState,io)
  50. end
  51. end
  52. end
  53. if io.UserInputState == Enum.UserInputState.Begin then
  54. m:TrigEvent("KeyDown",io.KeyCode.Name:lower())
  55. UIS:TrigEvent("InputBegan",io,false)
  56. else
  57. m:TrigEvent("KeyUp",io.KeyCode.Name:lower())
  58. UIS:TrigEvent("InputEnded",io,false)
  59. end
  60. end
  61. end)
  62. Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  63. end
  64.  
  65. hitboxdamagepart = Instance.new("Part",Player.Character)
  66. hitboxdamageweld = Instance.new("Weld",hitboxdamagepart)
  67. hitboxdamagepart.Transparency = 0.5
  68. hitboxdamagepart.Size = Vector3.new(5,5,0)
  69. hitboxdamagepart.Anchored = false
  70. hitboxdamagepart.CanCollide = false
  71. hitboxdamageweld.Part0 = Player.Character.Torso
  72. hitboxdamageweld.Part1 = hitboxdamagepart
  73. hitboxdamageweld.C0 = CFrame.new(0,0,-1)
  74. attack = false
  75. mouse.KeyDown:Connect(function(k)
  76. if k then
  77. print(k)
  78. end
  79. if k == "q" then
  80. attack = true
  81. hitboxdamagepart.Transparency = 0
  82. end
  83. end)
  84. mouse.KeyUp:Connect(function(k)
  85. if k == "q" then
  86. attack = false
  87. hitboxdamagepart.Transparency = 0.5
  88. end
  89. end)
  90. while wait(0.5) do
  91. if attack then
  92. hitboxdamagepart.Touched:Connect(function(hit)
  93. if hit.Parent.Name ~= Player.Name then
  94. print(hit.Parent.Name.." "..hit.Name)
  95. humhit = hit.Parent:FindFirstChildOfClass("Humanoid")
  96. if humhit.Health > 0 then
  97. humhit.Health = humhit.Health - 1
  98. end
  99. end
  100. end)
  101. end
  102. end
  103.  
  104.  
  105. --local script (client side script)
  106. local Player = game:GetService("Players").LocalPlayer
  107.  
  108. local Char = Player.Character
  109. local Event = Char:WaitForChild("UserInput_Event(loaded)")
  110.  
  111. local UIS = game:GetService("UserInputService")
  112.  
  113. local input = function(io,a)
  114. if a then return end
  115. local io = {KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState}
  116. Event:FireServer(io)
  117. end
  118. UIS.InputBegan:Connect(input)
  119. UIS.InputEnded:Connect(input)
  120. local Changed = false
  121. local Mouse = Player:GetMouse()
  122. local h,t = Mouse.Hit,Mouse.Target
  123. while wait(1/30) do
  124. if h~=Mouse.Hit or t~=Mouse.Target then
  125. Event:FireServer({isMouse=true,Target=Mouse.Target,Hit=Mouse.Hit})
  126. h,t=Mouse.Hit,Mouse.Target
  127. end
  128. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement