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

How would you go about making a sound play only local side not server side?

I have an intro script and it has audio triggers in it, but the problem is everyone can hear the audio. I tried spreading the spawns out and lowering the emitter range and max distance but that didnt work.

So I was wondering if there was a way to make the sound only play locally not server side like it is now.

Heres the code, it is a localscript under ReplicatedFirst because again its a intro GUI so it needed to be under ReplicatedFirst

But anyhow heres the code. Lines 24 ish and 16 ish are were the script starts to play the audio.

game.ReplicatedFirst:RemoveDefaultLoadingScreen()

local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
PlayerGui:SetTopbarTransparency(0)

local MainGUI = PlayerGui:WaitForChild("MainGUI")
local TutorialGUI = PlayerGui:WaitForChild("TutorialGUI")
local AudioFiles = game.Workspace.AudioStorage

MainGUI.MainMenu.Visible = false

-- Game group logo
wait(2)
MainGUI.Intro.Frog:TweenPosition(UDim2.new(.5, -250, .5, -250), "Out", "Bounce", 1.25)
wait(1)
AudioFiles.FrogCroak:Play()
AudioFiles.FrogCroak.EmitterSize = 5
AudioFiles.FrogCroak.MaxDistance = 5
wait(1)
MainGUI.Intro.Frog:TweenPosition(UDim2.new(-.5, -250, .5, -250), "In", "Quart", 1.25)
wait(2)

-- Main game menu
AudioFiles.IntroMusic:Play()
AudioFiles.IntroMusic.EmitterSize = 5
AudioFiles.IntroMusic.MaxDistance = 5
MainGUI.Intro.BackgroundColor3 = Color3.new(27/255, 42/255, 53/255)
MainGUI.Intro.Main:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Quart", 1.25)
wait(4)
MainGUI.Intro.Main:TweenSizeAndPosition(UDim2.new(15, 0, 15, 0), UDim2.new(-7, 0, -7.25, 0), "In", "Quart", 1.25)
wait(1.5)
MainGUI.MainMenu.Visible = true
MainGUI.MainMenu:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Quart", 1.5)
wait(.25)
for i = 1, .25, -0.025 do
	AudioFiles.IntroMusic.Volume = i
	wait()
end
MainGUI.Intro.Visible = false
TutorialGUI.Enabled = true
TutorialGUI.Tutorial.TypeWriterScript.Disabled = false
MainGUI.MainMenu.LoadSave:TweenPosition(UDim2.new(.6, 0, .025, 0), "Out", "Quad", 2)
wait(3)
MainGUI.MainMenu.LoadSave.Text = "SAVE LOADED!"
wait(1.5)
MainGUI.MainMenu.LoadSave:TweenPosition(UDim2.new(2, 0, .025, 0), "In", "Quad", 1)
wait(.5)
MainGUI.MainMenu.PlayerUnits:TweenPosition(UDim2.new(.6, 0, .025, 0), "Out", "Quad", 1.5)
wait(.25)
MainGUI.MainMenu.PlayerCrystals:TweenPosition(UDim2.new(.8, 0, .025, 0), "Out", "Quad", 1.5)

Dont judge all my waits, Its worked out so far XD

Thank you for your time :)

2 answers

✓ Accepted answer

Play the sound in SoundService.

sound.Parent = game.SoundService or, the better way, sound.Parent = game:GetService("SoundService")

2 comments

0

I dont even know how to use sound service, Ive been reading up on it and it seems more complex for such a simple situation.

0

Nvm I got it working ill accept your answer.

Change AudioFiles Parent to somewhere in StarterGui, and make it play from there.

local AudioFiles = PlayerGui:WaitForChild(“AudioStorage”)

What you did was you played the sound in workspace.

If this answer helped you, make sure to upvote!

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