Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

3 comments

1

Thanks, i appreciate it

0

You don't need Fire.Parent = Fireball, just do this, local Fire = Instance.new("Fire", Fireball), I commonly use this for ParticleEmitters too.

0

See my comment for incapaz's answer. @cherrythetree

This discussion is preserved as it was. New answers, comments, and votes are closed.