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

I'm making a sprint script (again) and It's animations aren't working properly. Can anyone help?

Asked by
ZIRFAL3 17
2 years ago
Edited 2 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Here's the script

local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local Animate = Character:WaitForChild("Animate")
local Animation = script.Parent:WaitForChild("Anim")
local Anim = Animation.AnimationId
local Original = Animate.walk.WalkAnim.AnimationId
local Running = script.Parent:WaitForChild("Running")

Running.Changed:Connect(function()

    print("Doing Stuff")

    if Humanoid.MoveDirection.Magnitude > 0 and Running.Value == true then

        Animate.walk.WalkAnim.AnimationId = Animation.AnimationId
        print("New Anim")

    else

        Animate.walk.WalkAnim.AnimationId = Original
        print("Old Anim")

    end

end)

The problem is that the animations aren't loading correctly, if you want to play the sprint animation, You can't do it while walking, You have to press shift before you start walking. If you want to stop the animation, you have to stop walking.

I've tried multiple scripts to do this.. But the problem isalways the same, The animations have trouble playing.

0
Make use of Humanoid:LoadAnimation() and UserInputService for inputs. KamKam_AJHasBeenBan 37 — 2y
0
why not write animation:stopped() change the id then animation:play again? u should try that. TheUltimateTNTFriend 109 — 2y
0
If I make it play, It will not stop, will it? ZIRFAL3 17 — 2y
0
i mean like every time ur gonna change the animation set the default one stop then change id then let new one play TheUltimateTNTFriend 109 — 2y
0
How can I sop the default animation if I don't have the Loaded animation variable? ZIRFAL3 17 — 2y

2 answers

Log in to vote
0
Answered by 2 years ago

You can change the Run animation of the character and the Walk animation if you want by going into the characters through a script and changing its animation settings.

local plr = game.Players.LocalPlayer
local char  = plr.Character
local Anims = char.Animate
local RunAnim = Anims.run.RunAnim

RunAnim.AnimationId = "http://www.roblox.com/asset/?id=YOURID"

if you want to change it permanently you can add this script to StarterCharacterScripts and change the animation so anytime that the player runs its animation should be changed already and you wont have to do it everytime they press shift, and roblox automatically decides when to play the run anim for you.

0
The thing is, the character is r6. And there's no RunAnim for R6 O_o ZIRFAL3 17 — 2y
0
@ZIRFAL3 im sure there is a RunAnim for R6 i converted my studio to R6 and went into the explorer and was able to find it. ahsan666666666666 264 — 2y
0
Yes, but to but the r6 run animation is just the walk animation sped up ZIRFAL3 17 — 2y
0
And I’m pretty sure it is not even used ZIRFAL3 17 — 2y
View all comments (4 more)
0
no I believe it is used, you can test it by setting your character speed to about 30 and go into the character and deleting the id for the run animation, and if the animation stops you’ll know it’s being used ahsan666666666666 264 — 2y
0
let me check.. ZIRFAL3 17 — 2y
0
no.. it didn't work.. ZIRFAL3 17 — 2y
0
if thats the case then instead of changing the RunAnim, change the WalkAnim? ahsan666666666666 264 — 2y
Ad
Log in to vote
0
Answered by
ZIRFAL3 17
2 years ago

I solved it! All I had to do was mae it so that the animation is loaded, played and immediatelly stopped, and let the animate script do the rest.

local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local Animate = Character:WaitForChild("Animate")
local Animation = script.Parent.Anim
local Anim = Animation.AnimationId
local OriginalAnim = Animate.walk.WalkAnim
local Original = Animate.walk.WalkAnim.AnimationId
local Running = script.Parent:WaitForChild("Running")

Running.Changed:Connect(function()

    print("Doing Stuff")

    if Humanoid.MoveDirection.Magnitude > 0 and Running.Value == true then

        Animate.walk.WalkAnim.AnimationId = Animation.AnimationId
        local Test2 = Humanoid:LoadAnimation(Animation)
        print("New Anim")

        if Humanoid.MoveDirection.Magnitude > 0 then

            Test2:Play()
            Test2:Destroy()

        end

    else

        Animate.walk.WalkAnim.AnimationId = Original
        local Test = Humanoid:LoadAnimation(OriginalAnim)
        print("Old Anim")

        if Humanoid.MoveDirection.Magnitude > 0 then

            Test:Play()
            Test:Destroy()

        end

    end

end)

Thanks to everyone who tried helping, even though You did not solve it, I really appreciate it!

Answer this question