Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script not changing animation on Left Shift????

When i press left shift i get error Play is not a valid member of Animation

local player = game.Players.LocalPlayer

	player.CharacterAdded:Connect(function(char)
		wait(1) 
		local mous = player:GetMouse()
		local humoid = player.Character:WaitForChild("Humanoid")
player.Character.Animate.walk.WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=2653244376"
		
		local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(Input)
    local MouseInput = Input.UserInputType
local KeyCode = Input.KeyCode

    if KeyCode == Enum.KeyCode.LeftShift then
        humoid.WalkSpeed = 30
player.Character.Animate.walk.WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=2654943642"
player.Character.Animate.walk.WalkAnim:Play()
    end
end)

UIS.InputEnded:connect(function(Input)
    local MouseInput = Input.UserInputType
local KeyCode = Input.KeyCode

if KeyCode == Enum.KeyCode.LeftShift then
        humoid.WalkSpeed = 16
player.Character.Animate.walk.WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=2653244376"
player.Character.Animate.walk.WalkAnim:Play()

    end
			
		end)
	end)

2 comments

0

I have script in PlayerGui LocalScriot

0

Bypassed it

1 answer

✓ Accepted answer

##Question

When i press left shift i get error Play is not a valid member of Animation

##Problem You don't call the :Play() method on the animation, you play it on the AnimationTrack which is returned from the :LoadHumanoid method of Humanoid

###Example Code

local humanoid = ... --// assumed reference to humanoid
local animation = ... --// assumed reference to an animation instance

local track = humanoid:LoadAnimation(animation)

track:Play()

This discussion is preserved as it was. New answers, comments, and votes are closed.