I have this footstep sound script, and I keep getting this error, what is happening?
-- Variables --
local playerService = game:GetService("Players")
local userInputService = game:GetService("UserInputService")
local localPlayer = playerService.LocalPlayer
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local mouse = localPlayer:GetMouse()
local footStepStorage = game.ReplicatedStorage:WaitForChild("FootstepLibrary")
local val = script:WaitForChild("StepValue")
local running = false
-- Settings --
local walkSpeed = 10
local runSpeed = 24
-- Animations --
-- Walk --
local animWalk = Instance.new("Animation")
animWalk.AnimationId = "rbxassetid://8899736432"
local walkAnim = humanoid:LoadAnimation(animWalk)
-- Run --
local animRun = Instance.new("Animation")
animRun.AnimationId = "rbxassetid://8899661986"
local runAnim = humanoid:LoadAnimation(animRun)
-- Idle --e
local animIdle = Instance.new("Animation")
animIdle.AnimationId = "rbxassetid://8899759590"
local idleAnim = humanoid:LoadAnimation(animIdle)
-- Main Functions --
function Footstep()
val.Value = humanoid.FloorMaterial.Name
local soundFolder = footStepStorage:FindFirstChild(val.Value)
local step = soundFolder[math.random(1, #soundFolder:GetChildren())]
-- print("Step on "..soundFolder.Name)
game.ReplicatedStorage.StepEvent:FireServer(character.Head,step)
-- local s = step:Clone()
-- s.Parent = character.Head
-- s:Destroy()
end
humanoid.Running:Connect(function(speed)
if speed > 0.05 and humanoid.WalkSpeed < runSpeed and not walkAnim.IsPlaying and not running then
idleAnim:Stop(0.5)
walkAnim:Play(0.5)
walkAnim:AdjustSpeed(humanoid.WalkSpeed/walkSpeed)
runAnim:Stop(0.5)
elseif speed < 0.05 then
walkAnim:Stop(0.5)
idleAnim:Play(0.5)
runAnim:Stop(0.5)
elseif speed > 0.05 and humanoid.WalkSpeed >= runSpeed and not runAnim.IsPlaying then
idleAnim:Stop(0.5)
walkAnim:Stop(0.5)
runAnim:Play(0.5)
runAnim:AdjustSpeed(humanoid.WalkSpeed / runSpeed)
end
end)
userInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
humanoid.WalkSpeed = runSpeed
running = true
end
end)
userInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
humanoid.WalkSpeed = walkSpeed
running = false
end
end)
walkAnim:GetMarkerReachedSignal("Footstep"):Connect(function()
if walkAnim.IsPlaying then
Footstep()
end
end)
runAnim:GetMarkerReachedSignal("Footstep"):Connect(function()
if runAnim.IsPlaying then
Footstep()
end
end)