i have a problem with my script, where everytime i activate the tool it doesn’t play the animation i want
could you please send the code here?
local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild(“Humanoid”)
local db = false
local function activated()
print(“yes”)
local eatanim = script.Parent.Animation
local eating = humanoid:LoadAnimation(eatanim)
eating:Play()
end
tool.Activated:Connect(activated)
is there any errors in the output?
i don’t think so
Roblox deprecated humanoid:LoadAnimation()
in favor of Animator:LoadAnimation()
. Please refer to this documentation of the new method.
Code Samples
This code sample includes a function that can be used to play an animation on a locally controlled model (such as a player character) from the server.
Animating a Model Locally
local function playAnimationFromServer(character, animation)
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
-- need to use animation object for server access
local animator = humanoid:FindFirstChildOfClass("Animator")
if animator then
local animationTrack = animator:LoadAnimation(animation)
animationTrack:Play()
return animationTrack
end
end
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507765644"
local character = script.Parent
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.