Advertisement
HowToRoblox

BowServer

Nov 5th, 2021
2,292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. local cooldown = false
  2.  
  3.  
  4. script.Parent.BowRE.OnServerEvent:Connect(function(plr, instruction, charge, mHit)
  5.    
  6.     if script.Parent.Parent == plr.Character and not cooldown and instruction == "shoot" then
  7.        
  8.         cooldown = true
  9.        
  10.         local newArrow = script.Parent.Arrow:Clone()
  11.         newArrow.Parent = workspace
  12.        
  13.         script.Parent.Arrow.Transparency = 1
  14.        
  15.        
  16.         newArrow.CFrame = CFrame.new(newArrow.Position, mHit.Position)
  17.        
  18.         newArrow.Velocity = mHit.LookVector * charge * 200
  19.        
  20.        
  21.         game:GetService("Debris"):AddItem(newArrow, 30)
  22.        
  23.        
  24.         local touched = false
  25.        
  26.         newArrow.Touched:Connect(function(hit)
  27.            
  28.             if hit.Parent ~= plr.Character and hit.Parent.Parent ~= plr.Character and not touched then
  29.                
  30.                 touched = true
  31.                
  32.                 newArrow:Destroy()
  33.                
  34.                 local humanoid = hit.Parent:FindFirstChild("Humanoid")
  35.                
  36.                 if humanoid then
  37.                     humanoid:TakeDamage(charge * 30)
  38.                 end
  39.             end
  40.         end)
  41.        
  42.        
  43.         script.Parent.BowRE:FireClient(plr, newArrow, charge)
  44.        
  45.        
  46.         wait(1)
  47.        
  48.         script.Parent.Arrow.Transparency = 0
  49.        
  50.         cooldown = false
  51.        
  52.        
  53.     elseif instruction == "string" then
  54.        
  55.         script.Parent.Bow.Middle.Position = charge
  56.         script.Parent.Bow.Weld.C1 = mHit
  57.     end
  58. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement