Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I prevent player-owned animations from overriding custom animations that I created?

Asked by
Rinpix 639 Moderation Voter
4 years ago
Edited 4 years ago

I've already searched around but Google keeps giving me completely unwanted topics that just happen to include the words that I'm using to describe my issue. I can't seem to find any other questions on ScriptingHelpers addressing this particular issue either.

Let's say I'm creating a pistol. A very simplistic pistol. I create an instance of a tool and I put a part with the name "Handle" in the tool.

By default, the character's right arm will be raised when the tool is equipped. I think it looks a little unnatural, and I want to adjust my character's arms so that both of the arms are held out in front of the character, so that my character is holding the pistol correctly.

I create an animation using the animation editor plugin with the R15 rig, and I publish it to the website. I inserted a LocalScript into the tool as well as an instance of an Animation. I put in the corresponding ID for the AnimationId property, and this is what I put into the LocalScript:

local anim = script.Parent:WaitForChild("Animation")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local anim_2 = humanoid:LoadAnimation(anim)

local tool = script.Parent

tool.Equipped:Connect(function()
    anim_2:Play()
end)

tool.Unequipped:Connect(function()
    anim_2:Stop()
end)

I threw this together in about a minute, so the variable placement may seem a little bit unconventional.

Anyways, it plays the animation whenever the player equips the tool. The thing is, the default R15 animations created by Roblox are immediately overriding the animation. The animation plays for a split second and is promptly overriden by the idling animations created by Roblox.

https://gyazo.com/aa5c73c0604ac57af7f964e8080d5c69

Just to be sure, I tweaked the length of the animation multiple times, ranging from 1 second to 5 seconds. The difference was nothing short of negligible.

How do I prevent default animations, created by Roblox, from overriding custom animations?

0
Maybe try deleting the player's animation with :Destroy() 6zk8 95 — 4y
0
I kind of want to blend the animations, and Roblox seems to be allowing that, but for some reason the animation immediately stops playing. Rinpix 639 — 4y
0
So for example if they are walking and they use the tool, they get the animation while still walking with the player owned animation. Do you mean that? 6zk8 95 — 4y
0
That already happens. My issue is that the animation plays for a split second and then immediately stops. I guess I could delete the walking/idling animations but that's not what I want. Rinpix 639 — 4y
View all comments (6 more)
0
First of all, check in the animation editor if the gaps are enough to see the difference 6zk8 95 — 4y
0
Huh? Rinpix 639 — 4y
0
I initially created the animation with a length of 1 second, and when it immediately stopped playing, I changed its length to 5 seconds to check to see if the length of the animation was the issue. Even if it was, increasing it didn't work either. Rinpix 639 — 4y
0
View your animation in the animation editor to see if every frame has time to change (and be view-able properly). 6zk8 95 — 4y
0
Oh. 6zk8 95 — 4y
0
Try adding some waits in your code maybe like wait(1). 6zk8 95 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

You have to set your animation's priority to the highest, and make sure your animation is looped. You can do this by editing your animation in Animation Editor.

Here is a similar question that could help you further: https://scriptinghelpers.org/questions/55786/how-do-i-make-an-idle-stance-for-tools

0
Thank you. I set the animation priority to the highest earlier but didn't know that I also had to make it loop. Rinpix 639 — 4y
Ad

Answer this question