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

Why isn't this script working? its says Idle is not a valid member

local LocalCharacter = script.Parent
local Animate = LocalCharacter:FindFirstChild("Animate")

do

	LocalCharacter.Animate.Idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=7391593289"
	LocalCharacter.Animate.Idle.Animation2.AnimationId = "http://www.roblox.com/asset/?id=7391593289"

end

1 answer

There's no context but there's no veriable that's called Idle. I also don't suggest putting the numbers in the script. For the knife I made I made four classesname.Animation's 1st was hit, 2nd was Idle, 3rd was left slash, and 4rth was right slash. So you're gonna wanna put the animations in the tool not in the handle.

local plr = game:GetService("Players").LocalPlayer
local anims = {script.Parent.Animation1, script.Parent.Animation2}
local loadedAnims = {}
local tool = script.Parent
local animator


 tool.Equipped:Connect(function(mouse)
	animator = plr.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
	if not loadedAnims[1] then
		loadedAnims[1] = animator:LoadAnimation(anims[1]) 
	end
	loadedAnims[1]:Play()

end)
tool.Unequipped:Connect(function()
	loadedAnims[1]:Stop()
end

Put the animation priority to action so it can be used on a tool. Haven't tested it just the Idle yet but I hope this works for you!

3 comments

0

Make sure it's a local script too.

0

So the reason is because the script didn't know what Idle was and you needed to play the animation on equipped not just do.

0

you see the local script is in starter player script and the idle is supposed to work with or without the tool, but i think ill try to use your anime variable to fix my script

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