Can you help me please? i inserted it into the starter pack on a local script with a animation inside of it i also has this error: Players.Tommytherox.Backpack.Run:1:attempt to index field 'Character' (a nil value) please help :(
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = "50" local playr = game.Players.LocalPlayer local mouse = playr:GetMouse() local animation = script:WaitForChild("Animation") local uis = game:GetService("UserInputService") local animationTrack = playr.Character.Humanoid:LoadAnimation(animation) function run(key,gp) if key.KeyCode == Enum.KeyCode.Q and gp == false then -- so it doesn't run when typing in chat etc. animationTrack:Play() script.Fwoosh:Play() game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = "250" end end uis.InputBegan:connect(run) function dont(key) if key.KeyCode == Enum.KeyCode.Q and gp == false then animationTrack:Stop() game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = "50" --how fast you will walk end end uis.InputEnded:connect(dont) wait() local animationTrack = playr.Character.Humanoid:LoadAnimation(animation)
You need to wait for the player's character before manipulating its children.
local playr = game.Players.LocalPlayer local mouse = playr:GetMouse() local animation = script:WaitForChild("Animation") local uis = game:GetService("UserInputService") local character = playr.CharacterAdded:wait() character:WaitForChild("Humanoid") character.Humanoid.WalkSpeed = 50 local animationTrack = playr.Character.Humanoid:LoadAnimation(animation) function run(key,gp) if key.KeyCode == Enum.KeyCode.Q and gp == false then -- so it doesn't run when typing in chat etc. animationTrack:Play() script.Fwoosh:Play() game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 250 end end uis.InputBegan:connect(run) function dont(key) if key.KeyCode == Enum.KeyCode.Q and gp == false then animationTrack:Stop() game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = "50" --how fast you will walk end end uis.InputEnded:connect(dont) wait() local animationTrack = playr.Character.Humanoid:LoadAnimation(animation)
Hope this helped.