Hi! I’ve been working on a game rn, I need to play footsteps sounds.
The problem is that my code is not actually working as expected here it is
function initPlayerSteppingSounds()
-- Footstep sounds
local LeftLegDetector = Instance.new("Part") -- Create a part for detecting the floor
local RightLegDetector = Instance.new("Part")
local CharLeftLeg : Part = Char["Left Leg"]
local CharRightLeg : Part = Char["Right Leg"]
LeftLegDetector.Parent = _SERVICES.Workspace
RightLegDetector.Parent = _SERVICES.Workspace
LeftLegDetector.Anchored = true
RightLegDetector.Anchored = true
LeftLegDetector.Size = Vector3.new(0.12, 0.04, 0.12)
RightLegDetector.Size = Vector3.new(0.12, 0.04, 0.12)
LeftLegDetector.Color = Color3.fromRGB(240,25,240)
RightLegDetector.Color = Color3.fromRGB(240,25,240)
_SERVICES.RunService.RenderStepped:Connect(function(dt)
LeftLegDetector.Position = Vector3.new(CharLeftLeg.Position.X, CharLeftLeg.Position.Y - 1.2, CharLeftLeg.Position.Z)
RightLegDetector.Position = Vector3.new(CharRightLeg.Position.X, CharRightLeg.Position.Y - 1.2, CharRightLeg.Position.Z)
end)
local SelectedSoundId
Hum.Running:Connect(function()
LeftLegDetector.Touched:Connect(function(basePart)
if basePart ~= CharLeftLeg then
print("Touched something")
if Hum.FloorMaterial == PlrStepsSounds[Hum.FloorMaterial] then
end
else
print("Touched Leg") -- testing
end
end)
end)
end
Btw don’t run this
If anyone could help, or tell me what to do it would be helpful, thanks!
Tell me if you need more details about it