Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to play custom footsteps sounds on server ?

Asked by 3 years ago

I am trying to make my own footstep sound effects depending on the material you are currently standing on. I have created a folder inside SoundService called 'Footsteps' and put all my custom sounds with the same name as some of the materials does have inside. Then I created a local script inside StarterCharacterScripts:

local Character = script.Parent
local rootpart = Character:WaitForChild("HumanoidRootPart")
local RunningSound = rootpart:WaitForChild("Running")
local FootstepsSoundGroup = game:GetService("SoundService"):WaitForChild("Footsteps")
local Humanoid = Character:WaitForChild("Humanoid")

Humanoid.Changed:Connect(function(property)

    if property == "FloorMaterial" then         
        if FootstepsSoundGroup:FindFirstChild(Humanoid.FloorMaterial) == nil then
            RunningSound.SoundId = FootstepsSoundGroup:WaitForChild("Plastic").SoundId
            RunningSound.PlaybackSpeed = FootstepsSoundGroup:WaitForChild("Plastic").PlaybackSpeed
            RunningSound.Volume = FootstepsSoundGroup:WaitForChild("Plastic").Volume
        else
            RunningSound.SoundId = FootstepsSoundGroup:WaitForChild(Humanoid.FloorMaterial).SoundId 
            RunningSound.PlaybackSpeed = FootstepsSoundGroup:WaitForChild(Humanoid.FloorMaterial).PlaybackSpeed
            RunningSound.Volume = FootstepsSoundGroup:WaitForChild(Humanoid.FloorMaterial).Volume
        end
    end
end)

The problem is the custom soundeffect plays LOCALY only for the player who is currently walking, other players hear the default roblox plastic foosteps. Is there a way to make everyone hear the correct sound effect?

1 answer

Log in to vote
0
Answered by
Necro_las 412 Moderation Voter
3 years ago

What i do is replicate the local sound to all clients with a remotem using :FireAllClients(), and remember to turn down the default step sound on charadded.

0
I found this a bit too complicated, so what I did is that I've created my own footstep script and disabled the original in 'RbxCharacterSounds' ninjabb2 0 — 3y
0
but this would take less then 5 lines ;-; Necro_las 412 — 3y
0
like remote:FireAllClients("ChangeStepSound", Player) remote.OnClientEvent:Connect(function(request, data) Player.Character.RootPart.Footsteps.SoundId = xxxxx end) Necro_las 412 — 3y
Ad

Answer this question