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

How do you make 1 death sound play locally and others hear only uhhh ?

Asked by
Bulvyte 388 Moderation Voter
9 years ago

I was messing with the studio and found this script and LocalSounds script, basically what i want this to do when player dies, the original sound from his head plays the ughh but for his client-side i want other sound to play.. How i DO DAT ?

i made a script that clones this into character where it was with the editted sound

function waitForChild(parent, childName)
    local child = parent:findFirstChild(childName)
    if child then return child end
    while true do
        child = parent.ChildAdded:wait()
        if child.Name==childName then return child end
    end
end

function newSound(name, id)
    local sound = Instance.new("Sound")
    sound.SoundId = id
    sound.Name = name
    sound.archivable = false
    sound.Parent = script.Parent.Head
    return sound
end

-- declarations

local sGettingUp = newSound("GettingUp", "rbxasset://sounds/action_get_up.mp3")
local sDied = newSound("Died", "rbxassetid://153239830") 
local sFreeFalling = newSound("FreeFalling", "rbxasset://sounds/action_falling.mp3")
local sJumping = newSound("Jumping", "rbxasset://sounds/action_jump.mp3")
local sLanding = newSound("Landing", "rbxasset://sounds/action_jump_land.mp3")
local sSplash = newSound("Splash", "rbxasset://sounds/impact_water.mp3")
local sRunning = newSound("Running", "rbxasset://sounds/action_footsteps_plastic.mp3")
sRunning.Looped = true
local sSwimming = newSound("Swimming", "rbxasset://sounds/action_swim.mp3")
sSwimming.Looped = true
local sClimbing = newSound("Climbing", "rbxasset://sounds/action_footsteps_plastic.mp3")
sClimbing.Looped = true

local Figure = script.Parent
local Head = waitForChild(Figure, "Head")
local Humanoid = waitForChild(Figure, "Humanoid")
local hasPlayer = game.Players:GetPlayerFromCharacter(script.Parent)
local filteringEnabled = game.Workspace.FilteringEnabled

local prevState = "None"

-- functions

function onDied()
    stopLoopedSounds()
    sDied:Play()
end

local fallCount = 0
local fallSpeed = 0
function onStateFall(state, sound)
    fallCount = fallCount + 1
    if state then
        sound.Volume = 0
        sound:Play()
        Spawn( function()
            local t = 0
            local thisFall = fallCount
            while t < 1.5 and fallCount == thisFall do
                local vol = math.max(t - 0.3 , 0)
                sound.Volume = vol
                wait(0.1)
                t = t + 0.1
            end
        end)
    else
        sound:Stop()
    end
    fallSpeed = math.max(fallSpeed, math.abs(Head.Velocity.Y))
end


function onStateNoStop(state, sound)
    if state then
        sound:Play()
    end
end


function onRunning(speed)
    sClimbing:Stop()
    sSwimming:Stop()
    if (prevState == "FreeFall" and fallSpeed > 0.1) then
        local vol = math.min(1.0, math.max(0.0, (fallSpeed - 50) / 110))
        sLanding.Volume = vol
        sLanding:Play()
        fallSpeed = 0
    end
    if speed>0.5 then
        sRunning:Play()
        sRunning.Pitch = 1.6
    else
        sRunning:Stop()
    end
    prevState = "Run"
end

function onSwimming(speed)
    if (prevState ~= "Swim" and speed > 0.1) then
        local volume = math.min(1.0, speed / 350)
        sSplash.Volume = volume
        sSplash:Play()
        prevState = "Swim"
    end
    sClimbing:Stop()
    sRunning:Stop()
    sSwimming.Pitch = 1.6
    sSwimming:Play()
end

function onClimbing(speed)
    sRunning:Stop()
    sSwimming:Stop()    
    if speed>0.01 then
        sClimbing:Play()
        sClimbing.Pitch = speed / 5.5
    else
        sClimbing:Stop()
    end
    prevState = "Climb"
end
-- connect up

function stopLoopedSounds()
    sRunning:Stop() 
    sClimbing:Stop()
    sSwimming:Stop()
end

if hasPlayer == nil then
    Humanoid.Died:connect(onDied)
    Humanoid.Running:connect(onRunning)
    Humanoid.Swimming:connect(onSwimming)
    Humanoid.Climbing:connect(onClimbing)
    Humanoid.Jumping:connect(function(state) onStateNoStop(state, sJumping) prevState = "Jump" end)
    Humanoid.GettingUp:connect(function(state) stopLoopedSounds() onStateNoStop(state, sGettingUp) prevState = "GetUp" end)
    Humanoid.FreeFalling:connect(function(state) stopLoopedSounds() onStateFall(state, sFreeFalling) prevState = "FreeFall" end)
    Humanoid.FallingDown:connect(function(state) stopLoopedSounds() end)
    Humanoid.StateChanged:connect(function(old, new) 
        if not (new.Name == "Dead" or 
                new.Name == "Running" or 
                new.Name == "RunningNoPhysics" or 
                new.Name == "Swimming" or 
                new.Name == "Jumping" or 
                new.Name == "GettingUp" or 
                new.Name == "Freefall" or 
                new.Name == "FallingDown") then
            stopLoopedSounds()
        end
    end)
end
0
Change the SoundId of the died sound located in the character's head. I can only provide a example script for you. Player.Character.Head.Died.SoundId = 'assetid' M39a9am3R 3210 — 9y
0
Could you help me ? Trough roblox i invited you to friends Bulvyte 388 — 9y

Answer this question