Why is this sound playing globally?

In a previous thread we solved an issued getting sounds to play locally. It works fine in most cases but not this one. I put this script in starter player scripts, if the function doesnt meet the level requirement it should play the sounds. Nogold is s place holder sound in this script.

The problem is, this script plays the sound globally when I am calling for it to play locally. Anyone know why?

local player = game.Players.LocalPlayer
local pad = game.Workspace.factionmodels["Male Orc Morph2"].Pad
local requiredlevel = 5
local debounce = false
local SoundService = game:GetService("SoundService")
	
pad.Touched:Connect(function(obj)
	local plr = game.Players:GetPlayerFromCharacter(obj.Parent)
	local playerLevel = plr.leaderstats.Level.Value
		
	local function playLocalSound(soundId)
		local sound = Instance.new("Sound")
		sound.SoundId = "rbxassetid://11222407921"
		SoundService:PlayLocalSound(sound)	
		
	end
			
	if not debounce then
		
		debounce = true
		
		if playerLevel < requiredlevel then
			playLocalSound()
			
		end
		
		task.wait(2)
		debounce = false
		
	end
	
end)

Instead of using SoundService it tries to play the audio without it, I think using that service will make it run on the whole server even if you request it on the client.

How would I call for a play local sound without sound service? I use this script with a prompt and it plays locally only.

Attempt putting the sound into the script (Parent it to the script)
This at least works in StarterGui, im not sure if it will work in StarterPlayerScripts

Adding on to what EZQ said, it’s fairly simple to just do this on a client side.
(Can be anywhere that allows local scripts)

script.Music:Play()

check is plr is the player

( I had the same issue too )

local player = game.Players.LocalPlayer
local pad = game.Workspace.factionmodels["Male Orc Morph2"].Pad
local requiredlevel = 5
local debounce = false
local SoundService = game:GetService("SoundService")

pad.Touched:Connect(function(obj)
	local plr = game.Players:GetPlayerFromCharacter(obj.Parent)
	
	if plr ~= Player then
		return
	end
	
	local playerLevel = plr.leaderstats.Level.Value

	local function playLocalSound(soundId)
		local sound = Instance.new("Sound")
		sound.SoundId = "rbxassetid://11222407921"
		SoundService:PlayLocalSound(sound)	

	end

	if not debounce then

		debounce = true

		if playerLevel < requiredlevel then
			playLocalSound()

		end

		task.wait(2)
		debounce = false

	end

end)

If you’re running a local test server make sure it’s muted. PlayLocalSound should play the sound locally.

I put a local script in starter gui. I put the sound in the script. The sound does play locally, but it does really strange things. If someone else steps on the part it plays the sound for me, but they cant hear it. It also breaks the original morph script. And it wont debounce.

local pad = game.Workspace.factionmodels["Male Orc Morph2"].Pad
local sound = script.nolevel
local player = game.Players.LocalPlayer
local debounce = false


pad.Touched:Connect(function(obj)
	local playerLevel = player.leaderstats.Level.Value
	local requiredLevel = 5
	if not debounce then

		debounce = true	
	
		if playerLevel < requiredLevel then
			sound:Play()
		end
		
		task.wait()
		debounce = false
		
	end	
	
end)

try this on the starter player scripts

local pad = game.Workspace.factionmodels["Male Orc Morph2"].Pad
local requiredlevel = 5
local debounce = false
local SoundService = game:GetService("SoundService")
	
pad.Touched:Connect(function(obj)
	local plr = game.Players:GetPlayerFromCharacter(obj.Parent)
	local playerLevel = plr.leaderstats.Level.Value
		
	local function playLocalSound(soundId)
		local sound = Instance.new("Sound")
		sound.SoundId = "rbxassetid://11222407921"
		SoundService:PlayLocalSound(sound)	
		
	end
			
	if not debounce and plr == player then
		
		debounce = true
		
		if playerLevel < requiredlevel then
			playLocalSound()
			
		end
		
		task.wait(2)
		debounce = false
		
	end
	
end)```
1 Like

Ok ill try this after some sleep. I didnt see the changes you made at first, but I see them now.

it will work, just trust me

(((

It did work, Thanks. Such small changes fixed everything.

1 Like