Hello, fellow helpers! I have a problem... I made a Shift to Run script but it doesn't seem to be working even though it looks fine to me. I've tried to put it in a StarterGUI too, but it doesn't work either.
Here's the LocalScript:
local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:wait()
local char = plr.Character or plr.Character.CharacterAdded:wait()
local humanoid = char.Humanoid
local RunR6 = script.Parent["Run (R6)"]
local RunR15 = script.Parent["Run (R15)"]
local PlayRunR6 = humanoid:LoadCharacter(RunR6)
local PlayRunR15 = humanoid:LoadCharacter(RunR15)
local UserInputService = game:GetService('UserInputService')
UserInputService.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
if Enum.HumanoidRigType.R6 then
humanoid.WalkSpeed = 24
PlayRunR6:Play()
elseif Enum.HumanoidRigType.R15 then
humanoid.WalkSpeed = 24
PlayRunR15:Play()
end
end
end)
This checks if you have pressed the Shift key on the left side of keyboard. If it is pressed, it triggers another if statement about detecting what RigType you're avatar is to determine what animation needs to be played (I made an R6 and R15 version of a running animation). When it sees this, it changes the humanoid's (player's) walkspeed to 24 and it plays the animation.

1 comment
You don't need the game.Players.PlayerAdded:wait(), LocalPlayer is always there when a localScript starts to run because LocalScripts are always within the player.