#Must make damage and part from local script show to all players.

7 messages · Page 1 of 1 (latest)

sick inlet
#

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
#

humanoid:TakeDamage(Damage)
end
fireball:Destroy()
end
end)

    delay(LifeTime, function()
        if fireball.Parent then
            fireball:Destroy()
        end
    end)

    cooldown = true
    wait(cooldown_time)
    cooldown = false
end

end

-- connect the onActivated function to the tool's Activated event
tool.Activated:Connect(onActivated)

#

if someone takes damage it wont shot for others

#

also if the fireball dosent show

#

the handle shows but not the fireball that i spawn

#

nvm it is fixed. idk how to close this

wraith sageBOT
#

studio** You are now Level 5! **studio