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

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

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

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    

	    

	    

	    

	    

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