Working on tool script

I’m looking to make a tool script but I can’t make the animation move. I’ve tried to use an animation instance and an animation in the workspace to make it work. I think the error might have to do something with the player.Humanoid

local UIS = game:GetService("UserInputService")
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://15046928442"

game.Players.LocalPlayer.Backpack.Flashlight.Equipped:Connect(function(player)
	print("Equipped!")
	local track = player.Humanoid:LoadAnimation(anim)
	track:Play()
end)
UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Q then
		script.Parent.Light.SpotLight.Brightness = 5
	end
end)

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		script.Parent.Light.SpotLight.Brightness = 0
	end
end)

Try player.Humanoid.Animator:LoadAnimation(anim).

1 Like

Sadly it doesn’t work, also in the output it says humanoid is not a valid member of Mouse “Instance”

Ah, my bad.

Looking at the tool documentation, it looks like the equipped event gives a parameter of the player’s mouse, not the player.
Try game.Players.LocalPlayer.Character.Humanoid.Animator:LoadAnimation(anim).

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.