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

how to play a animation from a script?

Asked by 3 years ago
Edited 3 years ago

So I have this script that shoots a fireball when you click a key everything works but I couldn't figure out how to add a animation to the script. I tried following many tutorials but none worked.

the script

local event = script.Parent:WaitForChild("Fire3")

local FireBall = script.Parent:WaitForChild("Balls")

local running = false

event.OnServerEvent:Connect(function(Player,MouseCF)
    local Char = Player.Character
    local Fire_Ball = FireBall:Clone()
    local BVol = Instance.new("BodyVelocity")
    BVol.MaxForce = Vector3.new(2000000,2000000,2000000)
    BVol.Velocity = MouseCF.LookVector * 0
    Fire_Ball.Anchored = false
    Fire_Ball.Transparency = 0
    Fire_Ball.Attachment.Fire.Enabled = true
    Fire_Ball.CFrame = Char.Torso.CFrame
    Fire_Ball.Parent = game.Workspace
    BVol.Parent = Fire_Ball
script.Animation:Play()

    local con = Fire_Ball.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= Player.Name and running == false then
            running = true
            print("Damage function triggered, "..hit.Parent.Name.." was damaged.")
            hit.Parent.Humanoid:TakeDamage(25)
            wait(3)
            running = false
        end
    end)

    print("Setup Fire ball damage function.")

    wait(3)
    con:Disconnect()
    Fire_Ball:Destroy()
    print("Cooldown finsihed, fire ball removed, and damage function disconnected.")
end)

Answer this question