Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How could i add fire to this fireball script i made?

Asked by
hh9man 5
6 years ago

Im new to lua and im not sure exactly how i could add fire to this fireball script.

game.Workspace.Fired.OnServerEvent:Connect(function(Player, Debounce)
    local AlreadyTouched = false
    local Character = Player.Character or Player.CharacterAdded:wait()
    Debounce = true
    local Fireball = Instance.new("Part")
    Fireball.Name = "Fireball"
    Fireball.Shape = Enum.PartType.Ball
    Fireball.Size = Vector3.new(3,3,3)
    Fireball.Material = Enum.Material.Neon
    Fireball.BrickColor = BrickColor.new("Deep orange")
    Fireball.CanCollide = false
    Fireball.Parent = Character
    Fireball.CFrame = Character.HumanoidRootPart.CFrame*CFrame.new(0,1,-6)
    local BV = Instance.new("BodyVelocity")
    BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
    BV.Velocity = Character.HumanoidRootPart.CFrame.lookVector*100
    BV.Parent = Fireball

    Fireball.Touched:Connect(function(Hit)
        local Humanoid = Hit.Parent:FindFirstChild("Humanoid")

        if Humanoid == nil then return end

        if AlreadyTouched == false then
            AlreadyTouched = true
            if Humanoid.Parent == Character then
                Humanoid.Health  = Humanoid.Health - 0
            else
                Humanoid.Health = Humanoid.Health - Humanoid.MaxHealth/4
            end
        end
    end)
    wait(2)
    Fireball:Destroy()
    Debounce = false
end)

2 answers

Log in to vote
2
Answered by
amanda 1059 Moderation Voter
6 years ago

Whenever you are creating the Fireball, also create the Fire.

It may be easier than you think.

Instance.new("Part") creates a part.

Instance.new("Fire") creates a fire.

The only other thing to do, is parent it to the Fireball.

game.Workspace.Fired.OnServerEvent:Connect(function(Player, Debounce)
    local AlreadyTouched = false
    local Character = Player.Character or Player.CharacterAdded:wait()
    Debounce = true
    local Fireball = Instance.new("Part")
    Fireball.Name = "Fireball"
    Fireball.Shape = Enum.PartType.Ball
    Fireball.Size = Vector3.new(3,3,3)
    Fireball.Material = Enum.Material.Neon
    Fireball.BrickColor = BrickColor.new("Deep orange")
    Fireball.CanCollide = false
    Fireball.Parent = Character
    Fireball.CFrame = Character.HumanoidRootPart.CFrame*CFrame.new(0,1,-6)
    local BV = Instance.new("BodyVelocity")
    BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
    BV.Velocity = Character.HumanoidRootPart.CFrame.lookVector*100
    BV.Parent = Fireball

    --adding fire
    local Fire = Instance.new("Fire")
    Fire.Parent = Fireball

    Fireball.Touched:Connect(function(Hit)
        local Humanoid = Hit.Parent:FindFirstChild("Humanoid")

        if Humanoid == nil then return end

        if AlreadyTouched == false then
            AlreadyTouched = true
            if Humanoid.Parent == Character then
                Humanoid.Health  = Humanoid.Health - 0
            else
                Humanoid.Health = Humanoid.Health - Humanoid.MaxHealth/4
            end
        end
    end)
    wait(2)
    Fireball:Destroy()
    Debounce = false
end)
1
Thanks, i appreciate it hh9man 5 — 6y
0
You don't need Fire.Parent = Fireball, just do this, local Fire = Instance.new("Fire", Fireball), I commonly use this for ParticleEmitters too. cherrythetree 130 — 6y
0
See my comment for incapaz's answer. @cherrythetree amanda 1059 — 6y
Ad
Log in to vote
1
Answered by 6 years ago
local fire = Instance.new("Fire", Fireball)

fire.Properties --set properties to have a custom effect. your choice obviously!
0
Using Instance.new() with the Parent argument is highly discouraged. Here is documentation for more information. http://wiki.roblox.com/index.php?title=Instance_(Data_Structure) http://devforum.roblox.com/t/psa-dont-use-instance-new-with-parent-argument/30296 amanda 1059 — 6y

Answer this question