local tool = script.Parent -- the tool object this script is attached to
local cooldown_time = script.Parent:WaitForChild("Values").Cooldown.Value
local cooldown = false
local fireball_speed = script.Parent:WaitForChild("Values").Fireball_Speed.Value
local LifeTime = script.Parent:WaitForChild("Values").LifeTime.Value
local Damage = script.Parent:WaitForChild("Values").Damage.Value
-- function to handle when the player clicks while holding the tool
local function onActivated()
if not cooldown then
print("Fireball used.")
-- add code here to shoot the fireball in the direction of the player's mouse
local character = tool.Parent
local player = game.Players:GetPlayerFromCharacter(character)
local mouse = player:GetMouse()
local fireball = Instance.new("Part")
fireball.Size = Vector3.new(4, 4, 4)
fireball.BrickColor = BrickColor.new("Bright orange")
fireball.CanCollide = false
fireball.Position = tool.Handle.Position
fireball.Transparency = 1
local fire = Instance.new("Fire")
fire.Size = 15
fire.Heat = 20
fire.TimeScale = 10
fire.Parent = fireball
local direction = (mouse.Hit.p - character.Head.Position).unit
local velocity = direction * fireball_speed
fireball.Velocity = velocity
fireball.Parent = game.Workspace
-- add constant force to fireball to prevent it from falling
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.Velocity = velocity
bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyVelocity.P = 1000
bodyVelocity.Parent = fireball
fireball.Touched:Connect(function(part)
if part.Parent ~= character and part.CanCollide then
local humanoid = part.Parent:FindFirstChild("Humanoid")
if humanoid then
** You are now Level 5! **