I looked at all the splints, everything twisted in my head. But there are no ideas. Can you tell me?
What are you currently using for this?
I’m checking in the usual script, which is located in the HumanoidRootPart of the player. What kind of material it stands on and whether it moves. If it moves, I select the desired sound (they are also in HumanoidRootPart) and play it.
UPD: Script:
`local runtime = game:GetService(‘RunService’)
local materials = script.Parent.Sounds:GetChildren()
local plr = game.Players.LocalPlayer
local char = script.Parent.Parent
local hrp = char.HumanoidRootPart
local hum = script.Parent.Parent.Humanoid
local walking
hum.Running:connect(function(speed)
if speed > hum.WalkSpeed/2 then
walking = true
else
walking = false
end
end)
function getMaterial()
local floormat = hum.FloorMaterial
if not floormat then floormat = ‘Air’ end
local matstring = string.split(tostring(floormat),‘Enum.Material.’)[2]
local material = matstring
return material
end
local lastmat
runtime.Heartbeat:connect(function()
if walking then
local material = getMaterial()
if material ~= lastmat and lastmat ~= nil then
materials[lastmat].Playing = false
end
local materialSound = materials[material]
materialSound.PlaybackSpeed = hum.WalkSpeed/14
materialSound.Playing = true
lastmat = material
else
for _,sound in pairs(materials:GetChildren()) do
sound.Playing = false
end
end
end)`
Basically what you’ll have to do is this: (In a serverscript)
game.Players.PlayerAdded:Connect(function(plr)
local runtime = game:GetService(‘RunService’)
local char = plr.Character
local materials = char.HumanoidRootPart.Sounds:GetChildren()
local hrp = char.HumanoidRootPart
local hum = char.Humanoid
end)
You basically just have to do everything from inside this PlayerAdded function
PS: To format a script, use ``` rather than just `