-- Roblox character sound script local Players = game:GetService("Players") local…
- User
-- Roblox character sound script
local Players = game:GetService("Players") local RunService = game:GetService("RunService")
local SOUND_DATA = { Climbing = { SoundId = "rbxasset://sounds/bfsl-minifigfoots1.mp3", Looped = true, }, Died = { SoundId = "rbxassetid://12222058", }, FreeFalling = { SoundId = "rbxassetid://12222200", Looped = true, }, GettingUp = { SoundId = "rbxasset://sounds/splat.wav", }, Jumping = { SoundId = "rbxassetid://12222200", }, Landing = { SoundId = "rbxasset://sounds/hit.wav", }, Running = { SoundId = "rbxasset://sounds/bfsl-minifigfoots1.mp3", Looped = true, }, Splash = { SoundId = "rbxasset://sounds/impact_water.mp3", }, Swimming = { SoundId = "rbxasset://sounds/action_swim.mp3", Looped = true, Pitch = 1.6, }, }
-- wait for the first of the passed signals to fire local function waitForFirst(...) local shunt = Instance.new("BindableEvent") local slots = {...}
codelocal function fire(...) for i = 1, #slots do slots[i]:Disconnect() end return shunt:Fire(...) end for i = 1, #slots do slots[i] = slots[i]:Connect(fire) end return shunt.Event:Wait()end
-- map a value from one range to another local function map(x, inMin, inMax, outMin, outMax) return (x - inMin)*(outMax - outMin)/(inMax - inMin) + outMin end
local function playSound(sound) sound.TimePosition = 0 sound.Playing = true end
local function shallowCopy(t) local out = {} for k, v in pairs(t) do out[k] = v end return out end
local function initializeSoundSystem(player, humanoid, rootPart) local sounds = {}
code - Assistant
To fix the issue where you can't hear the footsteps unless you jump first, you need to ensure that the transition for the
Runningstate is handled when the character first spawns. Currently, the initial state setup when the player is added does not seem to handle this correctly.You can initialize the
activeStateand then manually call the state transition function for theRunningstate if the humanoid is already in that state when the character is added.Here's the specific modification you need to make:
- Initialize the
activeStateproperly: Change the line whereactiveStateis set to also manually trigger the state transition if needed.
Find this part of the script:
lualocal activeState = stateRemap[humanoid:GetState()] or humanoid:GetState()Replace it with:
lua - Initialize the
- User
i think you sent me something by mistake
- Assistant
I apologize for any confusion. Let's address the issue directly.
You need to ensure that the initial
Runningstate is handled properly. The problem is likely that the initial state is not transitioning toRunningautomatically when the character spawns, so theRunningsound doesn't start playing.To fix this, manually trigger the sound state transition for
Runningif the character is already running when the sound system is initialized.- Modify the
initializeSoundSystemfunction: After setting up the sounds and state transitions, check if the humanoid is already in theRunningstate and trigger the corresponding state transition.
- Modify the