Advertisement
beati_kay

axe local script 2

May 7th, 2024
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local RunService = game:GetService("RunService")
  3. local UserInputService = game:GetService("UserInputService")
  4. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  5.  
  6. local axe = script.Parent
  7. local chopFolder = workspace.chop
  8. local player = Players.LocalPlayer
  9. local mouse = player:GetMouse()
  10. local equipped
  11.  
  12. axe.Equipped:Connect(function()
  13.     equipped = true
  14. end)
  15.  
  16. axe.Unequipped:Connect(function()
  17.     equipped = false
  18.     if cut then
  19.         cut:Destroy()
  20.     end
  21. end)
  22.  
  23. axe.Activated:Connect(function()
  24.     if cut and target:IsDescendantOf(chopFolder) then
  25.         ReplicatedStorage.events.cut:FireServer(target, cut.CFrame)
  26.     end
  27. end)
  28.  
  29. RunService.RenderStepped:Connect(function()
  30.     if equipped then
  31.         target = mouse.Target
  32.         if target and target:IsDescendantOf(chopFolder) and not (target.Name == "cut") then
  33.             if not workspace:FindFirstChild("cut") then
  34.                 cut = ReplicatedStorage.cut:Clone()
  35.                 cut.Size = Vector3.new(target.Size.X + 0.01, 0.1, target.Size.Z + 0.01)
  36.                 cut.Parent = workspace
  37.             end
  38.             cut.CFrame = target.CFrame * CFrame.new(0, target.CFrame:PointToObjectSpace(mouse.Hit.Position).Y, 0)
  39.         elseif cut then
  40.             cut:Destroy()
  41.         end
  42.     end
  43. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement