Advertisement
seeseekeepeeshee

Untitled

Jun 6th, 2025
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. local tool = script.Parent
  2. local remoteEvent = tool:WaitForChild("FireProjectile")
  3.  
  4. remoteEvent.OnServerEvent:Connect(function(player, targetPosition)
  5. local character = player.Character
  6. if not character then return end
  7.  
  8. local origin = character:FindFirstChild("Head") or character:FindFirstChild("HumanoidRootPart")
  9. if not origin then return end
  10.  
  11. -- Create projectile
  12. local projectile = Instance.new("Part")
  13. projectile.Shape = Enum.PartType.Ball
  14. projectile.Size = Vector3.new(1, 1, 1)
  15. projectile.BrickColor = BrickColor.new("Bright red")
  16. projectile.Material = Enum.Material.Neon
  17. projectile.Anchored = false
  18. projectile.CanCollide = true
  19. projectile.Position = origin.Position + Vector3.new(0, 2, 0)
  20. projectile.Parent = workspace
  21.  
  22. -- Launch it
  23. local direction = (targetPosition - projectile.Position).Unit
  24. local bodyVelocity = Instance.new("BodyVelocity")
  25. bodyVelocity.Velocity = direction * 100
  26. bodyVelocity.MaxForce = Vector3.new(1e5, 1e5, 1e5)
  27. bodyVelocity.Parent = projectile
  28.  
  29. -- Damage on hit
  30. projectile.Touched:Connect(function(hit)
  31. if hit:IsDescendantOf(character) then return end -- Don't hit self
  32. local hum = hit.Parent:FindFirstChild("Humanoid")
  33. if hum then
  34. hum:TakeDamage(25)
  35. end
  36. projectile:Destroy()
  37. end)
  38.  
  39. game.Debris:AddItem(projectile, 5)
  40. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement