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

How do i make a sound play on the player when he triggers it?

I have a script that plays a sound when you touch a invisible block (its supposed to be played when the player touches an invisible barrier when falling off the map

local SoundID = 613031470
local Block = script.Parent
local Debounce = false

Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. SoundID)

wait(1/30)

Block.Touched:connect(function(Hit)
    if Debounce == false then
        Debounce = true
        local Hum = Hit.Parent:findFirstChild("Humanoid")
        if Hum then
            local Sound = Instance.new("Sound", Workspace)
            Sound.Volume = 1
            Sound.SoundId = "http://www.roblox.com/asset/?id=" .. SoundID
            Sound.Looped = false
            Sound.Pitch = 1
            Sound.Archivable = false
            Sound:Play()
        end
    end
end)

And i cannot really figure i out how to make it play not in the workspace, but on the player who triggered the sound. (Basically make the player who fell off "Scream", not make the scream sound play for the whole server.) Im kinda new to scripting, so yeah...

1 comment

0

Put the invisible trigger inside of your camera in workspace when the game starts, that way only a client can trigger the scream.

1 answer

Create the sound in a LocalScript. Anything created or played through a LocalScript as opposed to a regular "Script" will only run for the client. In other words, if you simply transfer your code into a LocalScript, it should only play the sound for the individual user and not the whole server.

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