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

Why won't the animation play in this script in the tool?

Asked by 6 years ago

The animation won't play in this script. I don't know what I did wrong. There are no errors in the script, someone please help!

wait(2)
local uis = game:GetService("UserInputService")
local cloud = game.ReplicatedStorage:WaitForChild("Cloud")
local explosion = game.ReplicatedStorage:WaitForChild("Explosion")
local tool = script.Parent
local field = false
local isEquipped = false
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")


tool.Equipped:Connect(function()
    isEquipped = true
end)
tool.Unequipped:Connect(function()
    isEquipped = false
end)

function flarefire()
    local anim = Instance.new("Animation")
    anim.AnimationId = "rbxassetid:/987186796"
    local at = humanoid:LoadAnimation(anim)
    at:Play()
    wait(0.5)
    local clone = explosion:Clone()
    clone.Parent = game.Workspace
    clone.Position = character.HumanoidRootPart.Position + Vector3.new(0, -2, 0)

end



uis.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.Keyboard then
        if input.KeyCode == Enum.KeyCode.R and isEquipped and not field then
            print("Flare Fire!")
            field = true
            flarefire()
            wait(5)
            field = false
        end
    end
end)

1 answer

Log in to vote
0
Answered by 6 years ago

its cuz your useing a invailed anim id or put in the front of flarefire()

function flarefire()
local anim = Instance.new("Animation")
local anim WaitForChild:anim
anim.AnimationId = "rbxassetid:/987186796"      
local at = humanoid:LoadAnimation(anim)
at:Play()       
wait(0.5)   
local clone = explosion:Clone()    
clone.Parent = game.Workspace
clone.Position = character.HumanoidRootPart.Position + Vector3.new(0, -2, 0)
try that    








Ad

Answer this question