Tweening a sound in LocalScript replicates to other clients

Hi all,
I’m looking for a solution to what I believe should be a simple issue, but I can seem to fully wrap my head around why this is occurring. I’ve done some prior research online, and I can’t find any legitimate solution.

Here is the code:

local TS = game:GetService("TweenService")
local PlayerHitboxes = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")

--Change volume of music
local ManageVolume = function(SoundEffect, VolumeNumber)
	TS:Create(SoundEffect, TweenInfo.new(1), {Volume = VolumeNumber}):Play()
end


--Manage main pizzeria hitboxes
for i,v in pairs(game.Workspace.MusicHitboxes:GetChildren()) do
	v.Touched:Connect(function(PlayerTouched)
		if PlayerTouched == PlayerHitboxes then
			ManageVolume(v.MusicVal.Value, 0.75)
		end
	end)
	
	v.TouchEnded:Connect(function(PlayerTouched)
		if PlayerTouched == PlayerHitboxes then
			ManageVolume(v.MusicVal.Value, 0)
		end
	end)
end

(v.MusicVal is an ObjectValue which traces to a Sound found within game.Workspace.Audios)

As the title says, this code is within a LocalScript, but the volume tweens are replicating to all clients instead of only a single player.

Isn’t it because this is a Global sound, not a local sound?

When this post was created, the script was located in StarterGui.

I’ve moved it to StarterPlayerScripts, and this was the fix to my issue.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.