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

How do you make animations work with keys, and how would you add something like a fireball?

Asked by 10 years ago

How do you make a script, where if you press a key, a fireball appears, how do you position the fireball, and how do you make an animation play, and when it's done then the fireball appears?

  • I need help on this, because I have not learned this.

1 answer

Log in to vote
0
Answered by
Damo999 182
10 years ago
  1. i created the OnKeyDown function
  2. i create the part i wanted to shoot 3.i added a BodyVelocity 4.i added fire

I did not feel like doing the whole script so there is no damage nor animations ill tell you how to do damage.

--to do damage all you do is 

fireball.Touched:connect(function(hit)
    local hum = hit.Parent:findFirstChild("Humanoid")
    if hum then
        hum:TakeDamage(10)
    end
end)

--here is the script i made

game.Players.PlayerAdded:connect(function()
    mouse = game.Players.LocalPlayer:GetMouse()

    function onKeyDown(key) -- key down
        if key == "r" then
            fireball = Instance.new("Part",Workspace) --part i want to shoot
            fireball.Shape = 0
            fireball.BrickColor = BrickColor.new(21)
            fireball.Transparency = 0.5 --change to what you want
            fireball.Size = Vector3.new(4,4,4)
            fireball.CFrame = game.Players.LocalPlayer.Character.Torso.CFrame
            fireball.CFrame = fireball.CFrame *CFrame.new(0,0,-5)
            b = Instance.new("BodyVelocity") -- body velocity
            b.maxForce = Vector3.new(math.huge,math.huge,math.huge)
            b.velocity = game.Players.LocalPlayer.Character.Torso.CFrame.lookVector * 50
            b.Parent = fireball
            f = Instance.new("Fire",fireball) -- fire
            f.Size = 10
        end
    end
    mouse.KeyDown:connect(onKeyDown)
end)



Ad

Answer this question