Footstep system not working when everything is where there supposed

Hi developers I made a footstep sound system but the script is giving a bunch of errors everything is where there supposed to be. I tried editing it but it’s the same thing can you tell me the problem and how to fix it so it doesn’t happen again.

Screenshot


image
image

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(plr)
		local contentProvideder= game:GetService("ContentProvider")
		local hum = char.Humanoid
		
		
		local soundids = (
			brick = "rbxassetid://379398649"
			concrete = "rbxassetid://510934212"
			dirt/gravel = "rbxassetid://549000724"
			fabric = "rbxassetid://151760062"
			granite = "rbxassetid://379483672"
			grass = "rbxassetid://510933218"
			metal = "rbxassetid://549006073"
			pebble = "rbxassetid://379483672"
			sand = "rbxassetid://134456884"
			snow = "rbxassetid://510932495"
			water = "rbxassetid://510936382"
			wood = "rbxassetid://510935326"
		)
		local leftSounds = {}
		local rightSounds = {}
		local function convertToSoundObj (id)
			local sound = Instance.new("Sound")
			local urlAndMaterial = string.split(id, "")
			id = urlAndMaterial[2]
			sound.SoundId = id 
			sound.Name = name
			sound.Emittersize = 3
			sound.MaxDistance = 30
			
			if name == "brick" then
				sound.Volume = 0.5
			end
			
			if name == "concrete" then
				sound.Volume = 0.5
			end
			
			if name == "dirt/gravel" then
				sound.Volume = 0.5	
			end
			--			
			if name == "fabric" then
				sound.Volume = 0.5	
			end
			
			if name == "granite" then
				sound.Volume = 0.5	
			end
			
			if name == "grass" then
				sound.Volume = 0.5	
			end
			
			if name == "metal" then
				sound.Volume = 0.5	
			end
			
			if name == "pebble" then
				sound.Volume = 0.5	
			end
			
			if name == "sand" then
				sound.Volume = 0.5	
			end
			
			if name == "snow" then
				sound.Volume = 0.5	
			end
			
			if name == "water" then
				sound.Volume = 0.5	
			end
			
			if name == "wood" then
				sound.Volume = 0.5	
			end
			
			
			
			for _, in pairs (soundids) do
				local sound = convertToSoundObj (v)
				sound.Parent = char.LeftFoot
				leftsounds[#leftsound + 1 = sound]
			end
			
				for _, in pairs (soundids) do
					local sound = convertToSoundObj (v)
					sound.Parent = char.RightFoot
				rightsounds[#Rightsound + 1 = sound]	
			end
			
			contentProvider:PreloadAsync(leftsounds)
			contentProvider:PreloadAsync(rightsounds)
	end)
end)

game:GetService("ReplicatedStorage").Sound.OnServerEvent:Connect(function(plr, foot)
	local char = plr.Character
	local hum = char.Humanoid
	
	local function findsound(obj,name)
		local s = obj:FindFirstChild(name)
		return s 
	end
	
	local function soundplay(foot, material)
		if material == "woodplanks" then material = "wood" end
		if material == "" then material = "" end
		if material == "" then material = "" end
		if material == "" then material = "" end
		if material == "" then material = "" end
		if material == "" then material = "" end
		if foot:FindFirstChild(material) == nil then return end
		findSound(foot,material):pla()
	end
	soundPlay(foot,hum.FloorMaterial.Name
end)
1 Like

Theres so many issues with this script it’s frightening. For example, you’ve misspelt :Play(), never defined variables i.e. name, you never ended the function unless you expect it to be recursive in which case it will infinitely loop, you’re not returning any values and not using elseifs but thats the least of my concern. Why are you making inner functions if you don’t expect to use closures?

In total, it’s really hard to put a pin in it’s definitive issue when there are multiple scattered across the code. I believe the best course of action would be to rewrite it all.

im new to scripting and it took me awhile to make this

You should probably read the errors of your script because it would definitely tell you something.

Examples: ‘contentProvider’ is misspelt, you’ve defined it as ‘contentProvideder’ and are trying to use it as ‘contentProvider’.

You’ve defined a table ‘soundsids’ using parentheses () instead of brackets {}.

The console output would tell you about these issues, it is advised that you look at this first before posting for help, and if you do post for help include the error as well.

1 Like
local soundids = {
			brick  "rbxassetid://379398649"
			concrete = "rbxassetid://510934212"
			dirt = "rbxassetid://549000724"
			fabric = "rbxassetid://151760062"
			granite = "rbxassetid://379483672"
			grass = "rbxassetid://510933218"
			metal = "rbxassetid://549006073"
			pebble = "rbxassetid://379483672"
			sand = "rbxassetid://134456884"
			snow = "rbxassetid://510932495"
			water = "rbxassetid://510936382"
			wood = "rbxassetid://510935326"
		}

is it fixed?

This kinda looks like a yandere dev script

  1. Your local function convertToSoundObj has no end statement, the compiler itself should terminate the script.
  2. Your for...do loops’ second parameters are missing. It is just for_, in pairs(), should be for _,v in pairs()
  3. Your soundPlay() function’s invocation is incomplete, ) is missing.
  4. A table is declared with (). Declare it with {}.
  5. The insertion method for the tables are all wrong. It should be table[index] = value, not table[index = value].
  6. The logic of your convertToSoundObj() uses the key as material and value as the sound ID. Try implementing that.
  7. Try using tables to reduce the number of if...then statements. They are a lot more efficient and powerful.
  8. The entries in your table are not separated by commas. Try adding those after each entry.

There might be a lot more issues. You should try to learn how each operation works in Lua. That should make it simpler for you to write functional scripts!

I fixed some of the errors but the rest I couldn’t finish because I don’t know how to fix these parts of the script:

if name == " " then

findSound(foot,material):play() end soundPlay(foot,hum.FloorMaterial.Name)

local hum = char.Humanoid

Screenshot



Script
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(plr)
		local contentProvideder = game:GetService("ContentProvider")
			
		
		
		local soundids = {
			brick = "rbxassetid://379398649";
			concrete = "rbxassetid://510934212";
			dirt = "rbxassetid://549000724";
			fabric = "rbxassetid://151760062";
			granite = "rbxassetid://379483672";
			grass = "rbxassetid://510933218";
			metal = "rbxassetid://549006073";
			pebble = "rbxassetid://379483672";
			sand = "rbxassetid://134456884";
			snow = "rbxassetid://510932495";
			water = "rbxassetid://510936382";
			wood = "rbxassetid://510935326";
		}
		
		local leftSounds = {}
		local rightSounds = {}
		
		local function convertToSoundObj (id)
			local sound = Instance.new("Sound")
			local urlAndMaterial = string.split(id, "")
			id = urlAndMaterial[2]
			sound.SoundId = id 
			sound.Name = name
			sound.Emittersize = 3
			sound.MaxDistance = 30
			
			if name == "brick" then
				sound.Volume = 0.5
			end
			
			if name == "concrete" then
				sound.Volume = 0.5
			end
			
			if name == "dirt/gravel" then
				sound.Volume = 0.5	
			end
			--			
			if name == "fabric" then
				sound.Volume = 0.5	
			end
			
			if name == "granite" then
				sound.Volume = 0.5	
			end
			
			if name == "grass" then
				sound.Volume = 0.5	
			end
			
			if name == "metal" then
				sound.Volume = 0.5	
			end
			
			if name == "pebble" then
				sound.Volume = 0.5	
			end
			
			if name == "sand" then
				sound.Volume = 0.5	
			end
			
			if name == "snow" then
				sound.Volume = 0.5	
			end
			
			if name == "water" then
				sound.Volume = 0.5	
			end
			
			if name == "wood" then
				sound.Volume = 0.5	
			end
			
			
			
			for _, v in pairs (soundids) do
				local sound = convertToSoundObj (v)
				sound.Parent = char.LeftFoot
				leftSounds[#leftSounds + 1] = sound
			end
			
				for _, in pairs (soundids) do
					local sound = convertToSoundObj (v)
					sound.Parent = char.RightFoot
				rightSounds[#rightSounds + 1] = sound	
			end
			
			contentProvider:PreloadAsync(leftSounds)
			contentProvider:PreloadAsync(rightSounds)
	end
end)

game:GetService("ReplicatedStorage").Sound.OnServerEvent:Connect(function(plr, foot)
	local char = plr.Character
	local hum = char.Humanoid
	
	local function findsound(obj,name)
		local s = obj:FindFirstChild(name)
		return s 
	end
	
	local function soundplay(foot, material)
		if material == "woodplanks" then material = "wood" end
		if material == "" then material = "" end
		if material == "" then material = "" end
		if material == "" then material = "" end
		if material == "" then material = "" end
		if material == "" then material = "" end
		if foot:FindFirstChild(material) == nil then return end
		findSound(foot,material):play()
	end
		
	soundPlay(foot,hum.FloorMaterial.Name)
		
	
end)

Please help I am literally pulling my hair out right now trying to figure this out.