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

Why does my animation dosen't plays while holding my tool?

I really don't know anymore I made a bottle with a drink animation but I cannot let it play it dosen't prints any error. I don't think there is anything wrong in my script:

script.Parent.Activated:Connect(function()
	local char = script.Parent.Parent
	local track = char.Humanoid:LoadAnimation(script.Animation)
	track:Play()
end)

4 comments

0

Is RequiresHandle set to false?

0

It isn't set to false it is on true

0

what kind of script did u write it in? Script or Local Script

0

Local script

1 answer

✓ Accepted answer

This is a classic, unfortunately, I'm not sure if ROBLOX did this or why, but I believe they've deprecated the .Activated method of Tool. So to temporarily fix this, use a MouseClick event; it's best to apply this method with UserInputService to allow us to use the GameProcessed method to ignore a Click [for example] of a GUI, or more generically a ClickDetector.

local UserInputService = game:GetService("UserInputService")
local Tool = --// Reference Tool

Tool.Equipped:Connect(function() --// Restrict the Event to run as the Tool is Equipped.
	UserInputService.InputBegan:Connect(function(InputObject, GameProcessed)
		if (InputObject.UserInputType == Enum.UserInputType.MouseButton1) then
			if not (GameProcessed) then
				local char = script.Parent.Parent	    
				local track = char.Humanoid:LoadAnimation(script:WaitForChild("Animation")
				track:Play()
			end
		end
	end)
end)

Hope this helps out! don't forget to accept and upvote! anything confusing? Comment!

If these are new to you, consider reading about them here: UserInputType, UserInputService

2 comments

0

Activated is not deprecated. And it's not a method either. Neither is GameProcessed. It's an event. GameProcessed is a bool. Please use proper terminology when answering.

0

I’m not trying to actually tie the terminology with the Event, I actually meant method as use this form of doing things. Jeeez, lay off

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