plytalent

force attack

Sep 24th, 2021 (edited)
1,058
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.23 KB | None | 0 0
  1. script.Parent = owner.PlayerGui
  2. local part = nil
  3. local dwn = false
  4. local mouse_fd = Instance.new("Folder",script)
  5. mouse_fd.Name = "Mouse"
  6. local m1d,m1u,kd,updateposition = Instance.new("RemoteEvent",mouse_fd), Instance.new("RemoteEvent",mouse_fd), Instance.new("RemoteEvent",mouse_fd), Instance.new("RemoteEvent",mouse_fd)
  7. m1d.Name = "Button1Down"
  8. m1u.Name = "Button1Up"
  9. kd.Name = "KeyDown"
  10. local oldownership = nil
  11. updateposition.Name = "Update_Hit_Target"
  12. local mouse = {
  13.     ["Button1Down"]=m1d.OnServerEvent,
  14.     ["Button1Up"]=m1u.OnServerEvent,
  15.     ["KeyDown"]=kd.OnServerEvent,
  16.     Hit = CFrame.new(0,0,0),
  17.     Target = nil
  18. }
  19. updateposition.OnServerEvent:Connect(function(plr,hit,target)
  20.     if plr ~= owner then
  21.         return
  22.     end
  23.     mouse.hit = hit
  24.     mouse.Hit = hit
  25.     mouse.target = target
  26.     mouse.Target = target
  27. end)
  28. mouse.KeyDown:Connect(function(plr,k)
  29.     if plr ~= owner then
  30.         return
  31.     end
  32.     if k == "t" and part ~= nil then
  33.         local clone = part:Clone()
  34.         clone.Parent = workspace
  35.         clone.Anchored = false
  36.         clone:ClearAllChildren()
  37.         clone.CanCollide = true
  38.         bp.Parent = clone
  39.         if part.Parent:FindFirstChildOfClass("Humanoid") then
  40.             part.Parent:FindFirstChildOfClass("Humanoid").PlatformStand = false
  41.         end
  42.         part:Destroy()
  43.         part = clone
  44.     end
  45. end)
  46.  
  47. mouse.Button1Down:Connect(function(plr)
  48.     if plr ~= owner then
  49.         return
  50.     end
  51.     if mouse ~= nil then
  52.         if mouse.Target ~= nil then
  53.             part = mouse.Target
  54.             oldownership = part:GetNetworkOwner()
  55.             bp = Instance.new("BodyPosition",part)
  56.             bp.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  57.             bp.Position = part.Position
  58.             dwn = true
  59.         end
  60.     end
  61.     while dwn do
  62.         game:GetService("RunService").Stepped:Wait()
  63.         bp.Position = mouse.Hit.p
  64.         if part then
  65.             if part:GetNetworkOwner() ~= owner and not part.Anchored and part:IsDescendantOf(workspace) then
  66.                 part:SetNetworkOwner(owner)
  67.             end
  68.             if part.Parent:FindFirstChildOfClass("Humanoid") then
  69.                 part.Parent:FindFirstChildOfClass("Humanoid").PlatformStand = true
  70.             end
  71.         end
  72.     end
  73. end)
  74.  
  75. mouse.Button1Up:Connect(function(plr)
  76.     if plr ~= owner then
  77.         return
  78.     end
  79.     dwn = false
  80.     if part then
  81.         if part.Parent:FindFirstChildOfClass("Humanoid") then
  82.             part.Parent:FindFirstChildOfClass("Humanoid").PlatformStand = false
  83.         end
  84.         if part:GetNetworkOwner() ~= oldownership then
  85.             part:SetNetworkOwner(oldownership)
  86.         end
  87.         part = nil
  88.     end
  89.     if bp then
  90.         bp:Destroy()
  91.     end
  92. end)
  93. NLS([====[
  94.     local UpdateMouse = script.Parent.Mouse.Update_Hit_Target
  95.     local M1Down = script.Parent.Mouse.Button1Down
  96.     local M1Up = script.Parent.Mouse.Button1Up
  97.     local KDown = script.Parent.Mouse.KeyDown
  98.  
  99.     local mouse = owner:GetMouse()
  100.     local lasthit,lasttarget = mouse.Hit,mouse.Target
  101.     mouse.KeyDown:Connect(function(k)
  102.         KDown:FireServer(k)
  103.     end)
  104.     mouse.Button1Down:Connect(function()
  105.         M1Down:FireServer()
  106.     end)
  107.     mouse.Button1Up:Connect(function()
  108.         M1Up:FireServer()
  109.     end)
  110.     game:GetService("RunService").Heartbeat:Connect(function()
  111.         if mouse.Hit ~= lasthit or mouse.Target ~=lasttarget then
  112.             UpdateMouse:FireServer(mouse.Hit,mouse.Target)
  113.         end
  114.     end)
  115. ]====],script)
  116. print("Ready!")
Add Comment
Please, Sign In to add comment