Hello, I have a default audio for walking, and I need help with a script that changes the audio playback speed when left shift is pressed. Sorry if the script is kinda messy, still learning
local UIS = game:GetService("UserInputService") local KeyCode = Enum.KeyCode.LeftShift UIS.InputBegan:Connect(function(input, event) if input.KeyCode == KeyCode then local player = game.Players.LocalPlayer local sound = player.HumanoidRootPart:Waitforchild("Running")--audio i need to change sound.PlaybackSpeed = "2" end end)
I tried my best, what can I do to fix this?
You are trying to access a HumanoidRootPart, through a player, you may want to access the player's character, not the player itself. Also :Waitforchild is not a valid method, in Lua, caps are sensitive, you can easily mess up with a wrong uppercase/lowercase letter, instead use :WaitForChild.
Read this explanation ^ to prevent future errors.
Here is your fixed script:
local UIS = game:GetService("UserInputService") local KeyCode = Enum.KeyCode.LeftShift UIS.InputBegan:Connect(function(input, event) if input.KeyCode == KeyCode then local player = game.Players.LocalPlayer local sound = player.Character.HumanoidRootPart:WaitForChild("Running")--audio i need to change sound.PlaybackSpeed = "2" end end)