I’d like to make a system where if the player equip a Scroll (it’s a tool), an this animation will fire (the character opens the scroll and it ends in this position)
Since I’ve never applied any animation by script, I was wondering how could I solve this.
I was thinking to check if the tools is equipped by using a signal, then firing an event so the server can set the animation.
However I have no clue how to set animations and also how would i be able to know if the player doesn’t have the scroll equipped anymore?
This is what I tried (Local script).
local player = game:GetService("Players").LocalPlayer
local scrollTool = player.Backpack.Scroll
local animationID = "rbxassetid://000000" -- placeholder
local remoteEvent = game:GetService("ReplicatedStorage").Events.plrScroll
scrollTool.Equipped:Connect(function()
print("equipped")
remoteEvent:FireServer()
end)
Please correct me if I should do in another way, and how to apply animations.
local Animation = Instance.new("Animation") -- Create new animation
Animation.AnimationId = animationID -- Make sure to always format the animation id like: "rbxassetid://IDNUMBER"
Animation.Parent = player.Character -- Parent the animation where ever you want as it doesn't really matter
local AnimationTrack = player.Character.Humanoid.Animator:LoadAnimation(Animation) -- Load animation
-- The old way to load animations was "Humanoid:LoadAnimation()"
-- So just make sure to always use "Humanod.Animator:LoadAnimation()"
-- Player is holding the scroll
scrollTool.Equipped:Connect(function()
print("equipped")
AnimationTrack:Play()
end)
-- Player is no longer holding the scroll
scrollTool.Unequipped:Connect(function()
print("Unequipped")
AnimationTrack:Stop()
end)
Hi, thanks for helping. There’s two issues with this, the scroll isn’t getting played and also for some reason after the animation ends the arms get back to the idle position instead of staying up as they should.
after the animation ends, the player goes to the default idle animation? If so, and you don’t want that. Make sure to enable the “loop” option in moon animator, and then also try to set the “Animation Priority” to Action
I’ve set it already to Action, also I can’t make it loop cause otherwise it would repeat the animation (it starts with the scroll closed, which gets opened). I still don’t see the scroll appearing, was it maybe because I didn’t use no Welds at all for the Scroll?