-- Sound

CEs.PlaySound.OnClientEvent:connect(function(Sound,Rchr)
	if not Sound then return end
	if not Rchr then
		if Sound:IsDescendantOf(plr.Character) then return end
	else
		if plr.Character == Rchr then return end
	end
	
	local newSound = Instance.new("Sound", Sound.Parent)
	newSound.SoundId = Sound.SoundId
	newSound.PlaybackSpeed = Sound.PlaybackSpeed
	newSound.Volume = Sound.Volume
	newSound.Name = Sound.Name.."Playing"
	newSound:Play()
	game:GetService("Debris"):AddItem(newSound, Sound.TimeLength)
end)

CEs.StopSound.OnClientEvent:connect(function(Sound,Rchr)
	if not Sound then return end
	if not Rchr then
		if Sound:IsDescendantOf(plr.Character) then return end
	else
		if plr.Character == Rchr then return end
	end
	local newSound = Sound.Parent:FindFirstChild(Sound.Name.."Playing")
	if newSound then newSound:Destroy() end
end)
