I made a cup which when you click, it makes a slurp noise, How could i make it to where when i click it also plays a drink animation?
Use
--Gets the local player
local player = game:GetService("Players").LocalPlayer
--Gets the animation
local anim = player.Character.Humanoid:LoadAnimation(YOURANIMATIONPATH)
--Plays the animation
anim:Play()
Put it in the same script where the sound script is, if it isnt local then make a local one and use that script instead with the activated function
2 Likes
Updating your sound script, you can use the same .Activated function to play the animation. Just replace the animation ID with your animation ID.
--Variables
local selectedTool = script.Parent
--Sound variable
local sound = Instance.new("Sound")
sound.Parent = selectedTool
--Plays crab rave
sound.SoundId = "rbxassetid://5410086218"
--NEW ANIMATION PART
------
local animator = script.Parent.Humanoid.animator
local drinkAnimation = Instance.new("Animation")
--CHANGE THE ANIMATION ID NUMBERS TO YOUR DRINKING ANIMATION
drinkAnimation.AnimationId = "rbxassetid://616163682"
local drinkAnimationTrack = animator:LoadAnimation(drinkAnimation)
------
--Activated fires when the player clicks while the tool is activated
selectedTool.Activated:Connect(function()
sound:Play()
drinkAnimationTrack:Play()
end)