Metal Sound affect

oh wait- It’s not working still.

I did make a few edits to my post. Also, this should be in a ServerScript located in StarterCharacterScripts. If it still does not work, show me any errors in the output window :+1:

1 Like

There does not seem to be errors, but I still don’t hear the walking sound.


I placed it in a script, inside StarterCharacterScripts
I checked the dev console, Apparently the error is on line 7, next to function.

On your screen it says “Expected end…” on line number 9. Did you forget to add an “end?”

@P1X3L_K1NG

In my opinion, I would not use .Touched to detect when they take a step, instead, you can take the default Animate script and edit it to use GetMarkerReachedSignal. What I did was downloaded the run and walk animation and just edited to add a marker, then I used GetMarkerReachedSignal to detect when they took a step and played sounds accordingly.

1 Like

I don’t think parenting a sound object to your left foot is a good idea, if you can’t hear it and there’s nothing wrong with the script itself, modify the volume property.

Still nothing. I added the end, and I checked the dev console. Output also for any other extra mistakes.

Send your entire script here please in a codeblock.

alright

local char = script.Parent
local soundTable = {
[“Metal”] = “rbxassetid://834851222”;
}
local debounce = false
local leftFoot = char:WaitForChild(“LeftFoot”)
leftFoot.Touched:Connect(function(hit)
if not debounce then
if hit.Parent ~= char and soundTable[hit.Material.Name] then
debounce = true
local sound = Instance.new(“Sound”)
sound.SoundId = soundTable[hit.Material.Name]
sound:Play()
Debris:AddItem(sound, 1)
wait(1) – time you want to wait before the sound can play again when touched
debounce = false
end
end
end

found the problem, the sound is not parented to anything. my bad

Where are you parenting this script to the player’s character?

Where are you parenting the sound now? Thought you did it before.
You’re playing the sound and using Debris to add it?

Looks very badly written with many flaws.

There is a property in the character’s humanoid callde FloorMaterial you can use it to detect what they are stepping on. There is no need for touch events.(pretty sure it works on terrain too)

You could just use FloorMaterial instead of detecting all this sorta stuff…

This also might help

1 Like

Ooh, well can you show me how to do that, literally i’ve just started really trying to script and so far I can only tween :sweat_smile:

I’ll try it, and look at the links. Lol scripting is confusing.

I insert a humanoid into workspace? Then what? If I’m wrong correct me.

Please notice im not a pro at scripting :neutral_face:

1 Like

It’s ok we all start somewhere xd

Fixed it yet?

Nope, experimenting at the moment, literally I can’t even Tween XD

In a LocalScript, inside of StarterCharacterScripts:
(Code from the link @Lightning_Splash replied with)

local Player = game.Players.LocalPlayer
local Character = Player.Character

local DefaultSound = Character.Head:WaitForChild("Running").SoundId

local MaterialTable = {
	[Enum.Material.Grass] = "rbxassetid://256575709"
}

local Assets = {"rbxassetid://256575709","rbxassetid://256575709"}
game:GetService("ContentProvider"):PreloadAsync(Assets)

Character.Humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
	local FloorMaterial = Character.Humanoid.FloorMaterial
	if MaterialTable[FloorMaterial] then
		Character.Head.Running.SoundId = MaterialTable[FloorMaterial]
	else
		Character.Head.Running.SoundId = DefaultSound
	end
end)

Hope this helps :slight_smile: