Advertisement
Quoteory

Fireball Local

Mar 11th, 2020
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local Quire = _G.Quire
  3. local ClientProjectileHandler = Quire("ClientProjectileHandler")
  4. local player = game.Players.LocalPlayer
  5. local character = player.Character or player.CharacterAdded:Wait()
  6. local rightHand = character:WaitForChild("RightHand")
  7. local mouse = player:GetMouse()
  8. local tool = script.Parent
  9. local remotesFolder = tool.Remotes
  10. local shootEvent = remotesFolder.ShootEvent
  11.  
  12. local toolStatsFolder = tool.Stats
  13. local toolStateFolder = tool.State
  14.  
  15. local PROJECTILE_TEMPLATE = toolStatsFolder.ProjectileTemplate.Value
  16. local MIN_SIZE = toolStatsFolder.MinSize.value
  17. local MAX_CHARGE = toolStatsFolder.MaxCharge.Value
  18. local CHARGE_SPEED = toolStatsFolder.ChargeSpeed.Value
  19. local CHARGE_INCREMENT = toolStatsFolder.ChargeIncrement.Value
  20. local SIZE_PER_CHARGE = toolStatsFolder.SizePerCharge.Value
  21. local DAMAGE = toolStatsFolder.Damage.Value
  22. local VELOCITY = toolStatsFolder.Velocity.Value
  23. local RANGE = toolStatsFolder.Range.Value
  24.  
  25. -- state
  26. local chargingPart = toolStateFolder.ChargingPart
  27. local charge = toolStateFolder.Charge
  28. local isCharging = toolStateFolder.IsCharging
  29.  
  30. local function shoot()
  31.     if isCharging.Value then
  32.         local size = (charge.Value * SIZE_PER_CHARGE)
  33.         size = MIN_SIZE + Vector3.new(size, size, size)
  34.        
  35.         local projectile = PROJECTILE_TEMPLATE:Clone()
  36.         projectile.Size = size
  37.         projectile.Parent = workspace
  38.        
  39.         local origin = rightHand.Position
  40.         local direction = (mouse.Hit.Position - origin).Unit
  41.         local velocity = direction * VELOCITY
  42.         local range = direction * RANGE
  43.         ClientProjectileHandler:FireProjectile(tool, origin, range, velocity, projectile, workspace)
  44.         shootEvent:FireServer(direction)
  45.     end
  46. end
  47.  
  48. tool.Deactivated:Connect(shoot)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement