足音を変更する方法【Roblox Studio】

方法

StarterCharacterScriptにLocalScriptを挿入します。

シンプルに足音を変更する場合

script:

local defaultSoundId = "rbxassetid://6805324730"

local char = script.Parent

local humanoid = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")

local footstepsSound = hrp:WaitForChild("Running")

footstepsSound.SoundId = defaultSoundId
footstepsSound.Volume = 1
footstepsSound.PlaybackSpeed = 1

音量とスピードがデフォルトで1ではないので調整します。

footstepsSound.Volume = 1
footstepsSound.PlaybackSpeed = 1

走っているマテリアルによって足音を変更する場合

script:

local materialSounds = 
	{
		[Enum.Material.Grass] = "rbxassetid://6682230434",
		[Enum.Material.Metal] = "rbxassetid://6682230434",
		[Enum.Material.DiamondPlate] = "rbxassetid://6682230434",
		[Enum.Material.Pebble] = "rbxassetid://6682230434",
		[Enum.Material.Wood] = "rbxassetid://6682230434",
		[Enum.Material.WoodPlanks] = "rbxassetid://6682230434",
		[Enum.Material.Plastic] = "rbxassetid://6682230434",
		[Enum.Material.SmoothPlastic] = "rbxassetid://6682230434",
		[Enum.Material.Sand] = "rbxassetid://6682230434",
	}
local defaultSoundId = "rbxasset://sounds/action_footsteps_plastic.mp3"

local char = script.Parent

local humanoid = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")

local footstepsSound = hrp:WaitForChild("Running")

humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
	
	local floorMat = humanoid.FloorMaterial
	local soundOfMat = materialSounds[floorMat]
	
	if soundOfMat then
		footstepsSound.SoundId = soundOfMat
	else
		footstepsSound.SoundId = defaultSoundId 
	end
end)

参考

デフォルトの音のIDがわかるページhttps://scriptinghelpers.org/questions/14538/way-to-delete-default-sound-foot-steps

コメントを残す

メールアドレスが公開されることはありません。