Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Footstep sound is still default for other players?

Hello, I am aware of the latest character sound changes, but I am unable to find a way to make this script work so other players have the same footstep noise. Currently the script only plays locally, so the player is the only person that can hear the footsteps. Thanks!

Here is the script located inside StarterPlayerScripts, if placed in workspace, it says Running is not a valid member of Part.

local player = game:GetService("Players").LocalPlayer

wait(3)
while true do
	wait()
if player.Character.Humanoid.FloorMaterial == Enum.Material.Grass then
	player.Character.HumanoidRootPart.Running.SoundId = "rbxassetid://5088435955"

	
	elseif player.Character.Humanoid.FloorMaterial == Enum.Material.Cobblestone then
	player.Character.HumanoidRootPart.Running.PlaybackSpeed = 1

	player.Character.HumanoidRootPart.Running.SoundId = "rbxassetid://5088490245"
	elseif player.Character.Humanoid.FloorMaterial == Enum.Material.Concrete then
	player.Character.HumanoidRootPart.Running.PlaybackSpeed = 1

	player.Character.HumanoidRootPart.Running.SoundId = "rbxassetid://5088490245"
	elseif player.Character.Humanoid.FloorMaterial == Enum.Material.Wood then
	player.Character.HumanoidRootPart.Running.PlaybackSpeed = 1

	player.Character.HumanoidRootPart.Running.SoundId = "rbxassetid://5088489793"
	elseif player.Character.Humanoid.FloorMaterial == Enum.Material.Sand then
	player.Character.HumanoidRootPart.Running.PlaybackSpeed = 1

	player.Character.HumanoidRootPart.Running.SoundId = "rbxassetid://5112521579"
end
end


1 answer

The problem here is that you are trying to change something about the game world that affects all players in a LocalScript. There isn't anything wrong with your script itself, but rather how it is implemented: changes like this should be done in a Script instead.

An important thing to remember is that, generally, if there is any change to the game world that affects all player (ex. a sound is being changed in a part, like you're doing here) then it has to be done in a Script. A LocalScript will carry out the action, but it will only be on the player's client who executed it.

So, most of the code should be placed in a Script. The only issue left is that a Script cannot find the LocalPlayer unless it's given to it. So, to do what you are trying to accomplish, you should use two scripts, a Script in an accessible location such as ServerScriptService, and a LocalScript in StarterPlayerScripts. These should be connected with a RemoteEvent or RemoteFunction. For what you're doing, a 'RemoteEvent' is best.

Here's an example of how to set up a RemoteEvent in psuedocode, assuming there is a RemoteEvent called "RemoteEvent" in ReplicatedStorage:

In the LocalScript:

local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")

if (floor sound should change) then
	remoteEvent:FireServer()
end

In the Script

local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")

function changeSound(player, sound) -- Player argument is always first
	-- Sound changed here
end

remoteEvent:OnServerEvent:Connect(changeSound)

Above all else, I recommend checking out the link I attached to learn how to use a RemoteFunction. The developer hub can give you a better explanation and understanding than I ever could.

https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

This is a good video tutorial if you're interested:

https://www.youtube.com/watch?v=4Dc_bri9mjs

This discussion is preserved as it was. New answers, comments, and votes are closed.