Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Debris = game:GetService("Debris")
- local RunService = game:GetService("RunService")
- local FireballEvent = ReplicatedStorage:WaitForChild("FireballEvent")
- local FIREBALL_SPEED = 35
- local FIREBALL_BOUNCE = 35
- local FIREBALL_LIFETIME = 5
- local HOMING_DISTANCE = 40
- FireballEvent.OnServerEvent:Connect(function(player)
- local character = player.Character
- if not character then return end
- -- Tiene el poder de fuego
- if character:GetAttribute("CanShootFire") ~= true then
- return
- end
- -- FireFlower debe estar equipada
- local fireFlower = character:FindFirstChild("fireBall")
- if not fireFlower then
- return
- end
- local root = character:FindFirstChild("HumanoidRootPart")
- if not root then return end
- -- 🔥 CREAR FIREBALL
- local fireball = Instance.new("Part")
- fireball.Name = "Fireball"
- fireball.Shape = Enum.PartType.Ball
- fireball.Size = Vector3.new(1.2, 1.2, 1.2)
- fireball.Color = Color3.fromRGB(255, 170, 0)
- fireball.Material = Enum.Material.Neon
- fireball.CanCollide = true
- fireball.CanTouch = true
- fireball.CanQuery = false
- fireball.Anchored = false
- fireball.CFrame = root.CFrame * CFrame.new(0, 0, -3)
- fireball.Parent = workspace
- -- ✨ Brillo
- local light = Instance.new("PointLight")
- light.Color = Color3.fromRGB(255, 170, 0)
- light.Brightness = 3
- light.Range = 8
- light.Parent = fireball
- -- 🔥 PartÃculas
- local particles = Instance.new("ParticleEmitter")
- particles.Texture = "rbxasset://textures/particles/fire_main.dds"
- particles.Rate = 30
- particles.Lifetime = NumberRange.new(0.15, 0.3)
- particles.Speed = NumberRange.new(1, 3)
- particles.SpreadAngle = Vector2.new(180, 180)
- particles.LightEmission = 1
- particles.Size = NumberSequence.new({
- NumberSequenceKeypoint.new(0, 0.7),
- NumberSequenceKeypoint.new(1, 0)
- })
- particles.Parent = fireball
- -- Dirección inicial
- local direction = root.CFrame.LookVector
- fireball.AssemblyLinearVelocity =
- direction * FIREBALL_SPEED
- + Vector3.new(0, FIREBALL_BOUNCE, 0)
- -- Evitar que mate al propio jugador
- local alreadyHit = false
- local connection
- connection = RunService.Heartbeat:Connect(function()
- if not fireball.Parent then
- connection:Disconnect()
- return
- end
- -- Buscar enemigo cercano
- local closestEnemy = nil
- local closestDistance = HOMING_DISTANCE
- for _, model in ipairs(workspace:GetChildren()) do
- if model:IsA("Model") and model ~= character then
- local humanoid = model:FindFirstChildOfClass("Humanoid")
- local enemyRoot = model:FindFirstChild("HumanoidRootPart")
- if humanoid and enemyRoot and humanoid.Health > 0 then
- local distance =
- (enemyRoot.Position - fireball.Position).Magnitude
- if distance < closestDistance then
- closestDistance = distance
- closestEnemy = model
- end
- end
- end
- end
- -- 🎯 Dirigirse al enemigo
- if closestEnemy then
- local enemyRoot =
- closestEnemy:FindFirstChild("HumanoidRootPart")
- if enemyRoot then
- local directionToEnemy =
- (enemyRoot.Position - fireball.Position).Unit
- fireball.AssemblyLinearVelocity =
- directionToEnemy * FIREBALL_SPEED
- end
- end
- end)
- -- 💥 Golpear enemigos
- fireball.Touched:Connect(function(hit)
- if alreadyHit then return end
- local enemy = hit:FindFirstAncestorOfClass("Model")
- if not enemy or enemy == character then
- return
- end
- local humanoid =
- enemy:FindFirstChildOfClass("Humanoid")
- if humanoid and humanoid.Health > 0 then
- alreadyHit = true
- -- 💥 Mata al enemigo
- humanoid.Health = 0
- fireball:Destroy()
- end
- end)
- Debris:AddItem(fireball, FIREBALL_LIFETIME)
- end)
Advertisement
Add Comment
Please, Sign In to add comment