Anyway to make the cancel function cancel the activate function? i want to make like a continue check to see if the player is stunned if there are stunned then stop the function.
local playerService = game:GetService("Players")
local Fireball = {
Name = "Fireball",
UniqueId = "SKILL_FIREBALL_001",
Cooldown = 5,
Description = "Launches a fiery projectile that explodes on impact!",
Type = "Offensive",
SupportsHold = true,
TapThreshold = 0.2,
MaxChargeTime = 3.0,
}
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local HitboxClass = require(ReplicatedStorage.Modules.HitboxClass)
local HitboxTypes = require(ReplicatedStorage.Modules.HitboxClass.Types)
local damagehandler = require(ServerScriptService:WaitForChild("Modules").DamageHandler)
function Fireball.Activate(character, skillUniqueId, skillName)
local plr = playerService:GetPlayerFromCharacter(character)
if not character or not character:FindFirstChildOfClass("Humanoid") or not character:FindFirstChild("HumanoidRootPart") then
return
end
task.spawn(function()
Cancel(character)
end)
local humanoidRootPart = character.HumanoidRootPart
local fireballPart = Instance.new("Part")
fireballPart.Shape = Enum.PartType.Ball
fireballPart.Size = Vector3.new(3, 3, 3)
fireballPart.BrickColor = BrickColor.new("Bright orange")
fireballPart.Material = Enum.Material.Neon
fireballPart.CanCollide = false
fireballPart.CanTouch = true
fireballPart.Anchored = false
fireballPart.Position = humanoidRootPart.Position + humanoidRootPart.CFrame.LookVector * 5 + Vector3.new(0, 2, 0)
fireballPart.Parent = game.Workspace
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyVelocity.Velocity = humanoidRootPart.CFrame.LookVector * 10
bodyVelocity.Parent = fireballPart
local trail = Instance.new("Trail")
trail.Attachment0 = Instance.new("Attachment", fireballPart)
trail.Attachment1 = Instance.new("Attachment", fireballPart)
trail.Lifetime = 0.5
trail.Enabled = true
trail.Parent = fireballPart
local params : HitboxTypes.HitboxParams = {
SizeOrPart = Vector3.new(5, 4, 5),
SpatialOption = "InBox",
DebounceTime = 0.5,
Debris = 5,
Debug = true,
Blacklist = { character },
LookingFor = "Humanoid",
VelocityPrediction = true,
UseClient = nil,
}
local hitbox, created = HitboxClass.new(params)
if not created then
return
end
hitbox:WeldTo(fireballPart, CFrame.new(0, 0, 0))
local alreadyHitInThisSwing = {}
hitbox.HitSomeone:Connect(function(victims)
for _, victimCharacter in ipairs(victims) do
local victimHum = victimCharacter:FindFirstChildOfClass("Humanoid")
if victimHum and victimHum.Health > 0 and not alreadyHitInThisSwing[victimCharacter] then
alreadyHitInThisSwing[victimCharacter] = true
local hitStatus = damagehandler.ApplyDamage(character, victimCharacter, 5, 20, 1)
local explosion = Instance.new("Explosion")
explosion.Position = fireballPart.Position
explosion.BlastRadius = 10
explosion.BlastPressure = 0
explosion.Parent = game.Workspace
game:GetService("Debris"):AddItem(explosion, 1)
fireballPart:Destroy()
end
end
end)
hitbox:Start()
game:GetService("Debris"):AddItem(fireballPart, 5)
end
function Fireball.StartHold(character, skillUniqueId, skillName)
if character then
local indicator = Instance.new("Part")
indicator.Name = "FireballChargeIndicator"
indicator.Size = Vector3.new(1, 1, 1)
indicator.Shape = Enum.PartType.Ball
indicator.BrickColor = BrickColor.new("Orange")
indicator.Transparency = 0.7
indicator.CanCollide = false
indicator.Anchored = false
local weld = Instance.new("WeldConstraint")
weld.Part0 = indicator
weld.Part1 = character.HumanoidRootPart
weld.Parent = indicator
indicator.Parent = character
end
end
function Fireball.ReleaseHold(character, skillUniqueId, skillName, holdDuration)
print("[FireballSkill:ReleaseHold] Released", skillName, "after", string.format("%.2f", holdDuration), "seconds.")
if character then
local indicator = character:FindFirstChild("FireballChargeIndicator")
if indicator then indicator:Destroy() end
end
local baseDamage = 1
local baseSpeed = 75
local maxChargeTime = Fireball.MaxChargeTime or 3
local damageMultiplier = math.min(1 + holdDuration / maxChargeTime, 2)
local finalDamage = baseDamage * damageMultiplier
local finalSpeed = baseSpeed * damageMultiplier
if not character or not character:FindFirstChildOfClass("Humanoid") or not character:FindFirstChild("HumanoidRootPart") then
return
end
local humanoidRootPart = character.HumanoidRootPart
local fireballPart = Instance.new("Part")
fireballPart.Shape = Enum.PartType.Ball
fireballPart.Size = Vector3.new(3, 3, 3)
fireballPart.BrickColor = BrickColor.new("Bright orange")
fireballPart.Material = Enum.Material.Neon
fireballPart.CanCollide = false
fireballPart.CanTouch = true
fireballPart.Anchored = false
fireballPart.Position = humanoidRootPart.Position + humanoidRootPart.CFrame.LookVector * 5 + Vector3.new(0, 2, 0)
fireballPart.Parent = game.Workspace
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyVelocity.Velocity = humanoidRootPart.CFrame.LookVector * finalSpeed
bodyVelocity.Parent = fireballPart
local trail = Instance.new("Trail")
trail.Attachment0 = Instance.new("Attachment", fireballPart)
trail.Attachment1 = Instance.new("Attachment", fireballPart)
trail.Lifetime = 0.5
trail.Enabled = true
trail.Parent = fireballPart
local function onFireballTouched(otherPart)
if otherPart.Parent == character then return end
if otherPart.Parent:FindFirstChildOfClass("Humanoid") then
local targetHumanoid = otherPart.Parent:FindFirstChildOfClass("Humanoid")
if targetHumanoid then
targetHumanoid:TakeDamage(finalDamage)
end
end
local explosion = Instance.new("Explosion")
explosion.Position = fireballPart.Position
explosion.BlastRadius = 10
explosion.BlastPressure = 0
explosion.Parent = game.Workspace
game:GetService("Debris"):AddItem(explosion, 1)
fireballPart:Destroy()
end
fireballPart.Touched:Connect(onFireballTouched)
game:GetService("Debris"):AddItem(fireballPart, 5)
end
function Cancel(character)
while true do
print(character)
if character:GetAttribute("Stunned") == true then
print("skill not fired")
return
else
print("not stunned")
end
task.wait(0.2)
end
end
return Fireball