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)
