I am trying to script a sprinting script with animations. To get the animations, I chose to edit the default roblox Animate value to the animation I want. This strategy works in R6 but not R15. The animation is R15, I have made sure of that.
if input.KeyCode == Enum.KeyCode.LeftControl and collection:HasTag(hum, "Sprinting") == false then
collection:AddTag(hum, "Sprinting")
character:FindFirstChild("Animate").run.RunAnim.AnimationId = "rbxassetid://5442218732"
_G.runAnim = "http://www.roblox.com/asset/?id=5442218732"
hum.WalkSpeed = 0
wait()
hum.WalkSpeed = 25
elseif input.KeyCode == Enum.KeyCode.LeftControl and collection:HasTag(hum, "Sprinting") then
collection:RemoveTag(hum, "Sprinting")
character:FindFirstChild("Animate").run.RunAnim.AnimationId = "rbxassetid://5442183357"
_G.runAnim = "http://www.roblox.com/asset/?id=5442183357"
hum.WalkSpeed = 0
wait()
hum.WalkSpeed = 16
end
The following code is in a user input service, input began event which is in a local script in StarterPack. I know I should use remotes to make this a bit more secure as well as a sanity check with the remote, however, I wanted to keep everything in 1 place for this question so currently its all in 1 local script. The _G.runAnim is a variable that defines the value of the run animation id from the animate script. I do know that the animation id does indeed change in the animation track object within the Animate script but it still doesn’t function for some reason. Thanks to all answers in advance.